3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = ' { "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -4.702540, 51.672791 ] }, "properties": { "Id": "1603", "Name": "TENBY", "Country": "Channel Islands", "ContinuousHeightsAvailable": true } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -1.878530, 50.721680 ] }, "properties": { "Id": "1603A", "Name": "Bournmouth", "Country": "Channel Islands", "ContinuousHeightsAvailable": true } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -2.35, 49.433333 ] }, "properties": { "Id": "1603A", "Name": "Maseline Pier", "Country": "Channel Islands", "ContinuousHeightsAvailable": true } }] }'; $locations = json_decode($json, true); #print_r($locations); $base_location = array( 'lat' => "51.672791", 'lng' => "-4.702540" ); $distances = array(); for ($c = 0; $c < count($locations["features"]); $c++) { echo "I = " .$c; } for ($c = 0; $c < count($locations["features"]); $c++) { foreach($locations as $i){ foreach ($i as $z) { foreach ($z['geometry'] as $key => $location) { if ($key == "coordinates"){ # print_r($z); $a = $base_location['lat'] - $location[1]; $b = $base_location['lng'] - $location[0]; $distance = sqrt(($a**2) + ($b**2)); $distances[$c] = $distance; echo "The value of key '$key' is '$location'", PHP_EOL; }} }} } print_r($base_location); asort($distances); print_r($distances); $closest = $location[key($distances)]; #print_r($closest); #echo "<br>Closest port from ARRAY is: " . $closest['features'][1]['properties']['Id'];

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.20.0110.00720.11
8.5.10.0140.00420.48
8.5.00.0120.00920.31
8.4.160.0110.01524.07
8.4.150.0010.00114.05
8.4.140.0190.01217.81
8.4.130.0060.01217.99
8.4.120.0040.00420.82
8.4.110.0110.01019.10
8.4.100.0110.00818.30
8.4.90.0110.01118.24
8.4.80.0050.00618.09
8.4.70.0060.00518.12
8.4.60.0110.01018.79
8.4.50.0120.00917.82
8.4.40.0130.00719.92
8.4.30.0130.01320.68
8.4.20.0090.01218.13
8.4.10.0090.00019.85
8.3.290.0130.00820.99
8.3.280.0150.00620.49
8.3.270.0080.01216.88
8.3.260.0140.00617.07
8.3.250.0110.00818.86
8.3.240.0090.00916.94
8.3.230.0030.00516.99
8.3.220.0100.00917.30
8.3.210.0040.00317.14
8.3.200.0060.00317.17
8.3.190.0100.00817.36
8.3.180.0080.00619.20
8.3.170.0060.00316.80
8.3.160.0100.00717.00
8.3.150.0100.01017.28
8.3.140.0060.00317.16
8.3.130.0090.00018.91
8.3.120.0030.00618.97
8.3.110.0050.00320.94
8.3.100.0080.00024.06
8.3.90.0130.00626.77
8.3.80.0000.00916.75
8.3.70.0160.00016.74
8.3.60.0110.00716.75
8.3.50.0000.01518.76
8.3.40.0110.00419.27
8.3.30.0070.00719.38
8.3.20.0050.00324.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.300.0120.00820.48
8.2.290.0140.00520.79
8.2.280.0090.01018.79
8.2.270.0120.00616.89
8.2.260.0120.00818.56
8.2.250.0070.00317.21
8.2.240.0090.00019.20
8.2.230.0090.00022.58
8.2.220.0030.00637.54
8.2.210.0030.01226.77
8.2.200.0090.00016.88
8.2.190.0160.00316.88
8.2.180.0120.00325.92
8.2.170.0060.00919.16
8.2.160.0100.00322.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00421.14
8.2.110.0000.00920.85
8.2.100.0090.00019.53
8.1.340.0120.01017.89
8.1.330.0130.00516.84
8.1.320.0060.00616.38
8.1.310.0100.01016.59
8.1.300.0030.00718.39
8.1.290.0060.00318.88
8.1.280.0160.00325.92
8.1.270.0040.00423.99
8.1.260.0090.00026.35
8.1.250.0070.00028.09
8.1.240.0000.00919.22
8.1.230.0070.00418.75
7.3.10.0030.00418.47
7.3.00.0090.00318.42

preferences:
110.8 ms | 403 KiB | 5 Q