3v4l.org

run code in 300+ PHP versions simultaneously
<?php function distance($lat1, $lon1, $lat2, $lon2, $unit) { $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; $unit = strtoupper($unit); if ($unit == "K") { return array($miles * 1.609344, " kilometers"); } else if ($unit == "N") { return array($miles * 0.8684, " nautical miles"); } else { return array($miles, " miles"); } } $r = distance(32.9697, -96.80322, 29.46786, -98.53506, "K"); echo round($r[0],2) . $r[1];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vnRFv
function name:  (null)
number of ops:  17
compiled vars:  !0 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'distance'
          1        SEND_VAL                                                 32.9697
          2        SEND_VAL                                                 -96.8032
          3        SEND_VAL                                                 29.4679
          4        SEND_VAL                                                 -98.5351
          5        SEND_VAL                                                 'K'
          6        DO_FCALL                                      0  $1      
          7        ASSIGN                                                   !0, $1
   22     8        INIT_FCALL                                               'round'
          9        FETCH_DIM_R                                      ~3      !0, 0
         10        SEND_VAL                                                 ~3
         11        SEND_VAL                                                 2
         12        DO_ICALL                                         $4      
         13        FETCH_DIM_R                                      ~5      !0, 1
         14        CONCAT                                           ~6      $4, ~5
         15        ECHO                                                     ~6
         16      > RETURN                                                   1

Function distance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 64
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 71
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vnRFv
function name:  distance
number of ops:  75
compiled vars:  !0 = $lat1, !1 = $lon1, !2 = $lat2, !3 = $lon2, !4 = $unit, !5 = $theta, !6 = $dist, !7 = $miles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
    5     5        SUB                                              ~8      !1, !3
          6        ASSIGN                                                   !5, ~8
    6     7        INIT_FCALL                                               'sin'
          8        INIT_FCALL                                               'deg2rad'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $10     
         11        SEND_VAR                                                 $10
         12        DO_ICALL                                         $11     
         13        INIT_FCALL                                               'sin'
         14        INIT_FCALL                                               'deg2rad'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $12     
         17        SEND_VAR                                                 $12
         18        DO_ICALL                                         $13     
         19        MUL                                              ~14     $11, $13
         20        INIT_FCALL                                               'cos'
         21        INIT_FCALL                                               'deg2rad'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $15     
         24        SEND_VAR                                                 $15
         25        DO_ICALL                                         $16     
         26        INIT_FCALL                                               'cos'
         27        INIT_FCALL                                               'deg2rad'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $17     
         30        SEND_VAR                                                 $17
         31        DO_ICALL                                         $18     
         32        MUL                                              ~19     $16, $18
         33        INIT_FCALL                                               'cos'
         34        INIT_FCALL                                               'deg2rad'
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                         $20     
         37        SEND_VAR                                                 $20
         38        DO_ICALL                                         $21     
         39        MUL                                              ~22     $21, ~19
         40        ADD                                              ~23     ~14, ~22
         41        ASSIGN                                                   !6, ~23
    7    42        INIT_FCALL                                               'acos'
         43        SEND_VAR                                                 !6
         44        DO_ICALL                                         $25     
         45        ASSIGN                                                   !6, $25
    8    46        INIT_FCALL                                               'rad2deg'
         47        SEND_VAR                                                 !6
         48        DO_ICALL                                         $27     
         49        ASSIGN                                                   !6, $27
    9    50        MUL                                              ~29     !6, 60
         51        MUL                                              ~30     ~29, 1.1515
         52        ASSIGN                                                   !7, ~30
   10    53        INIT_FCALL                                               'strtoupper'
         54        SEND_VAR                                                 !4
         55        DO_ICALL                                         $32     
         56        ASSIGN                                                   !4, $32
   12    57        IS_EQUAL                                                 !4, 'K'
         58      > JMPZ                                                     ~34, ->64
   13    59    >   MUL                                              ~35     !7, 1.60934
         60        INIT_ARRAY                                       ~36     ~35
         61        ADD_ARRAY_ELEMENT                                ~36     '+kilometers'
         62      > RETURN                                                   ~36
   12    63*       JMP                                                      ->74
   14    64    >   IS_EQUAL                                                 !4, 'N'
         65      > JMPZ                                                     ~37, ->71
   15    66    >   MUL                                              ~38     !7, 0.8684
         67        INIT_ARRAY                                       ~39     ~38
         68        ADD_ARRAY_ELEMENT                                ~39     '+nautical+miles'
         69      > RETURN                                                   ~39
   14    70*       JMP                                                      ->74
   17    71    >   INIT_ARRAY                                       ~40     !7
         72        ADD_ARRAY_ELEMENT                                ~40     '+miles'
         73      > RETURN                                                   ~40
   19    74*     > RETURN                                                   null

End of function distance

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.38 ms | 1015 KiB | 21 Q