3v4l.org

run code in 300+ PHP versions simultaneously
<?php $latitude = '1234'; $longitude = '4567'; $items = [ ['name' => 'me', 'latitude' => '1234', 'longitude' =>'4567'], ['name' => 'you', 'latitude' => '2345', 'longitude' =>'5678'] ]; $ref = array($latitude, $longitude); $distances = array_map(function($item) use($ref) { $a = array_slice($item, -2); return distance($a, $ref); }, $items); asort($distances); function distance($a, $b) { list($lat1, $lon1) = $a; list($lat2, $lon2) = $b; $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; return $miles; }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 0 in /in/R8Ig0 on line 23 Warning: Undefined array key 1 in /in/R8Ig0 on line 23 Deprecated: deg2rad(): Passing null to parameter #1 ($num) of type float is deprecated in /in/R8Ig0 on line 27 Deprecated: deg2rad(): Passing null to parameter #1 ($num) of type float is deprecated in /in/R8Ig0 on line 27 Warning: Undefined array key 0 in /in/R8Ig0 on line 23 Warning: Undefined array key 1 in /in/R8Ig0 on line 23 Deprecated: deg2rad(): Passing null to parameter #1 ($num) of type float is deprecated in /in/R8Ig0 on line 27 Deprecated: deg2rad(): Passing null to parameter #1 ($num) of type float is deprecated in /in/R8Ig0 on line 27

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
120.78 ms | 407 KiB | 5 Q