3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function eho($what, $label) { echo "\n\n" . $label . ': '; dump($what); echo "\n\n"; } function dump() { $args = func_get_args(); return call_user_func_array('var_dump', $args); } function ehobool($b, $label) { eho($b ? 'true' : 'false', $label); } function CalculateRegularFenceCoords ($fCentreLat, $fCentreLon, $fRadius, $iVertices) { //$a = shell_exec( // "node $shell_scripts_path/nodejs/calculate_regular_fence.js --www_path=$source_www_path " . // "--lat=$fCentreLat --lon=$fCentreLon --radius=$fRadius --vertices=$iVertices" //); //eho($a, 'shell_exec'); $a = '{"lats":["56.998210","56.998210","56.998279","56.998414","56.998610","56.998859","56.999152","56.999478","56.999824","57.000176","57.000522","57.000848","57.001141","57.001390","57.001586","57.001721","57.001789","57.001789","57.001721","57.001586","57.001390","57.001141","57.000848","57.000522","57.000176","56.999824","56.999478","56.999152","56.998859","56.998610","56.998414","56.998279","56.998210"],"lons":["24.000324","23.999676","23.999042","23.998444","23.997906","23.997448","23.997088","23.996841","23.996714","23.996714","23.996841","23.997088","23.997448","23.997906","23.998444","23.999042","23.999676","24.000324","24.000958","24.001556","24.002094","24.002552","24.002912","24.003159","24.003286","24.003286","24.003159","24.002912","24.002552","24.002094","24.001556","24.000958","24.000324"]}'; $aFenceCoords = json_decode($a, true); foreach ($aFenceCoords['lats'] as $i => $fLat) { convert2($aFenceCoords['lats'][$i], $aFenceCoords['lons'][$i], $aFenceCoords['xes'][$i], $aFenceCoords['ys'][$i]); } return $aFenceCoords; } $actual = CalculateRegularFenceCoords(57, 24, 200, 32); unset($actual['lats'], $actual['lons'], $actual['ys']); for ($i = 0; $i <= 31; ++$i) { unset($actual['xes'][$i]); } eho($actual, '$actual'); ehobool($actual["xes"][32] == 500019.68325692, '$actual["xes"][32] == 500019.68325692'); eho($actual["xes"][32], '$actual["xes"][32]'); $actual= array( "xes"=> array( 32=> 500019.68325692 ) ); eho($actual, '$actual'); ehobool($actual["xes"][32] == 500019.68325692, '$actual["xes"][32] == 500019.68325692'); eho($actual["xes"][32], '$actual["xes"][32]');
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function convert2() in /in/14D0K:30 Stack trace: #0 /in/14D0K(36): CalculateRegularFenceCoords(57, 24, 200, 32) #1 {main} thrown in /in/14D0K on line 30
Process exited with code 255.
Output for 5.2.0 - 5.6.28
Fatal error: Call to undefined function convert2() in /in/14D0K on line 30
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/14D0K on line 27
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/14D0K on line 27
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/14D0K on line 27
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/14D0K on line 27