3v4l.org

run code in 300+ PHP versions simultaneously
<?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]');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 12
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 12
Branch analysis from position: 17
Branch analysis from position: 12
filename:       /in/14D0K
function name:  (null)
number of ops:  53
compiled vars:  !0 = $actual, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'calculateregularfencecoords'
          1        SEND_VAL                                                 57
          2        SEND_VAL                                                 24
          3        SEND_VAL                                                 200
          4        SEND_VAL                                                 32
          5        DO_FCALL                                      0  $2      
          6        ASSIGN                                                   !0, $2
   38     7        UNSET_DIM                                                !0, 'lats'
          8        UNSET_DIM                                                !0, 'lons'
          9        UNSET_DIM                                                !0, 'ys'
   39    10        ASSIGN                                                   !1, 0
         11      > JMP                                                      ->15
   40    12    >   FETCH_DIM_UNSET                                  $5      !0, 'xes'
         13        UNSET_DIM                                                $5, !1
   39    14        PRE_INC                                                  !1
         15    >   IS_SMALLER_OR_EQUAL                                      !1, 31
         16      > JMPNZ                                                    ~7, ->12
   42    17    >   INIT_FCALL                                               'eho'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 '%24actual'
         20        DO_FCALL                                      0          
   43    21        INIT_FCALL                                               'ehobool'
         22        FETCH_DIM_R                                      ~9      !0, 'xes'
         23        FETCH_DIM_R                                      ~10     ~9, 32
         24        IS_EQUAL                                         ~11     ~10, 500020
         25        SEND_VAL                                                 ~11
         26        SEND_VAL                                                 '%24actual%5B%22xes%22%5D%5B32%5D+%3D%3D+500019.68325692'
         27        DO_FCALL                                      0          
   44    28        INIT_FCALL                                               'eho'
         29        FETCH_DIM_R                                      ~13     !0, 'xes'
         30        FETCH_DIM_R                                      ~14     ~13, 32
         31        SEND_VAL                                                 ~14
         32        SEND_VAL                                                 '%24actual%5B%22xes%22%5D%5B32%5D'
         33        DO_FCALL                                      0          
   46    34        ASSIGN                                                   !0, <array>
   53    35        INIT_FCALL                                               'eho'
         36        SEND_VAR                                                 !0
         37        SEND_VAL                                                 '%24actual'
         38        DO_FCALL                                      0          
   54    39        INIT_FCALL                                               'ehobool'
         40        FETCH_DIM_R                                      ~18     !0, 'xes'
         41        FETCH_DIM_R                                      ~19     ~18, 32
         42        IS_EQUAL                                         ~20     ~19, 500020
         43        SEND_VAL                                                 ~20
         44        SEND_VAL                                                 '%24actual%5B%22xes%22%5D%5B32%5D+%3D%3D+500019.68325692'
         45        DO_FCALL                                      0          
   55    46        INIT_FCALL                                               'eho'
         47        FETCH_DIM_R                                      ~22     !0, 'xes'
         48        FETCH_DIM_R                                      ~23     ~22, 32
         49        SEND_VAL                                                 ~23
         50        SEND_VAL                                                 '%24actual%5B%22xes%22%5D%5B32%5D'
         51        DO_FCALL                                      0          
         52      > RETURN                                                   1

Function eho:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/14D0K
function name:  eho
number of ops:  10
compiled vars:  !0 = $what, !1 = $label
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        CONCAT                                           ~2      '%0A%0A', !1
          3        CONCAT                                           ~3      ~2, '%3A+'
          4        ECHO                                                     ~3
    6     5        INIT_FCALL_BY_NAME                                       'dump'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
    7     8        ECHO                                                     '%0A%0A'
    8     9      > RETURN                                                   null

End of function eho

Function dump:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/14D0K
function name:  dump
number of ops:  8
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
   11     2        INIT_FCALL                                               'var_dump'
          3        SEND_ARRAY                                               !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      0  $3      
          6      > RETURN                                                   $3
   12     7*     > RETURN                                                   null

End of function dump

Function ehobool:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/14D0K
function name:  ehobool
number of ops:  11
compiled vars:  !0 = $b, !1 = $label
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        INIT_FCALL                                               'eho'
          3      > JMPZ                                                     !0, ->6
          4    >   QM_ASSIGN                                        ~2      'true'
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~2      'false'
          7    >   SEND_VAL                                                 ~2
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0          
   17    10      > RETURN                                                   null

End of function ehobool

Function calculateregularfencecoords:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 33
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 33
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/14D0K
function name:  CalculateRegularFenceCoords
number of ops:  36
compiled vars:  !0 = $fCentreLat, !1 = $fCentreLon, !2 = $fRadius, !3 = $iVertices, !4 = $a, !5 = $aFenceCoords, !6 = $fLat, !7 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   26     4        ASSIGN                                                   !4, '%7B%22lats%22%3A%5B%2256.998210%22%2C%2256.998210%22%2C%2256.998279%22%2C%2256.998414%22%2C%2256.998610%22%2C%2256.998859%22%2C%2256.999152%22%2C%2256.999478%22%2C%2256.999824%22%2C%2257.000176%22%2C%2257.000522%22%2C%2257.000848%22%2C%2257.001141%22%2C%2257.001390%22%2C%2257.001586%22%2C%2257.001721%22%2C%2257.001789%22%2C%2257.001789%22%2C%2257.001721%22%2C%2257.001586%22%2C%2257.001390%22%2C%2257.001141%22%2C%2257.000848%22%2C%2257.000522%22%2C%2257.000176%22%2C%2256.999824%22%2C%2256.999478%22%2C%2256.999152%22%2C%2256.998859%22%2C%2256.998610%22%2C%2256.998414%22%2C%2256.998279%22%2C%2256.998210%22%5D%2C%22lons%22%3A%5B%2224.000324%22%2C%2223.999676%22%2C%2223.999042%22%2C%2223.998444%22%2C%2223.997906%22%2C%2223.997448%22%2C%2223.997088%22%2C%2223.996841%22%2C%2223.996714%22%2C%2223.996714%22%2C%2223.996841%22%2C%2223.997088%22%2C%2223.997448%22%2C%2223.997906%22%2C%2223.998444%22%2C%2223.999042%22%2C%2223.999676%22%2C%2224.000324%22%2C%2224.000958%22%2C%2224.001556%22%2C%2224.002094%22%2C%2224.002552%22%2C%2224.002912%22%2C%2224.003159%22%2C%2224.003286%22%2C%2224.003286%22%2C%2224.003159%22%2C%2224.002912%22%2C%2224.002552%22%2C%2224.002094%22%2C%2224.001556%22%2C%2224.000958%22%2C%2224.000324%22%5D%7D'
   27     5        INIT_FCALL                                               'json_decode'
          6        SEND_VAR                                                 !4
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !5, $9
   29    10        FETCH_DIM_R                                      ~11     !5, 'lats'
         11      > FE_RESET_R                                       $12     ~11, ->33
         12    > > FE_FETCH_R                                       ~13     $12, !6, ->33
         13    >   ASSIGN                                                   !7, ~13
   30    14        INIT_FCALL_BY_NAME                                       'convert2'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_DIM_FUNC_ARG                               $15     !5, 'lats'
         17        FETCH_DIM_FUNC_ARG                               $16     $15, !7
         18        SEND_FUNC_ARG                                            $16
         19        CHECK_FUNC_ARG                                           
         20        FETCH_DIM_FUNC_ARG                               $17     !5, 'lons'
         21        FETCH_DIM_FUNC_ARG                               $18     $17, !7
         22        SEND_FUNC_ARG                                            $18
         23        CHECK_FUNC_ARG                                           
         24        FETCH_DIM_FUNC_ARG                               $19     !5, 'xes'
         25        FETCH_DIM_FUNC_ARG                               $20     $19, !7
         26        SEND_FUNC_ARG                                            $20
         27        CHECK_FUNC_ARG                                           
         28        FETCH_DIM_FUNC_ARG                               $21     !5, 'ys'
         29        FETCH_DIM_FUNC_ARG                               $22     $21, !7
         30        SEND_FUNC_ARG                                            $22
         31        DO_FCALL                                      0          
   29    32      > JMP                                                      ->12
         33    >   FE_FREE                                                  $12
   33    34      > RETURN                                                   !5
   34    35*     > RETURN                                                   null

End of function calculateregularfencecoords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.73 ms | 1411 KiB | 25 Q