3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sepNameDist($place){ $placeArr = explode("(",$place); if(count($placeArr)>1){ $array['name'] = ucwords(trim($placeArr[0])); $clean = strtolower(str_replace(" ","",trim(str_replace(")","",$placeArr[1])))); $matches = (preg_split('#(?<=\d)(?=[a-z])#i', $clean)); $num = $matches[0]; $txt = $matches[1]; if($num < 1 and (trim(strtolower($txt)) == "km" or (trim(strtolower($txt)) == "kms"))){ $num = $num*1000; $txt = "m"; $array['distance'] = $num." ".$txt; } else{ $array['distance'] = $num." ".$txt; } return $array; } else{ $placeArr = explode(" ",trim($place)); return $placeArr; } } print_r(sepNameDist("Birla Mandir 30 Km"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MgD12
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'sepnamedist'
          2        SEND_VAL                                                 'Birla+Mandir+30+Km'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function sepnamedist:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 79
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 47, Position 2 = 64
Branch analysis from position: 47
2 jumps found. (Code = 47) Position 1 = 55, Position 2 = 63
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 73
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 77
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
Branch analysis from position: 64
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MgD12
function name:  sepNameDist
number of ops:  89
compiled vars:  !0 = $place, !1 = $placeArr, !2 = $array, !3 = $clean, !4 = $matches, !5 = $num, !6 = $txt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%28'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
    5     6        COUNT                                            ~9      !1
          7        IS_SMALLER                                               1, ~9
          8      > JMPZ                                                     ~10, ->79
    6     9    >   INIT_FCALL                                               'ucwords'
         10        INIT_FCALL                                               'trim'
         11        FETCH_DIM_R                                      ~12     !1, 0
         12        SEND_VAL                                                 ~12
         13        DO_ICALL                                         $13     
         14        SEND_VAR                                                 $13
         15        DO_ICALL                                         $14     
         16        ASSIGN_DIM                                               !2, 'name'
         17        OP_DATA                                                  $14
    7    18        INIT_FCALL                                               'strtolower'
         19        INIT_FCALL                                               'str_replace'
         20        SEND_VAL                                                 '+'
         21        SEND_VAL                                                 ''
         22        INIT_FCALL                                               'trim'
         23        INIT_FCALL                                               'str_replace'
         24        SEND_VAL                                                 '%29'
         25        SEND_VAL                                                 ''
         26        FETCH_DIM_R                                      ~15     !1, 1
         27        SEND_VAL                                                 ~15
         28        DO_ICALL                                         $16     
         29        SEND_VAR                                                 $16
         30        DO_ICALL                                         $17     
         31        SEND_VAR                                                 $17
         32        DO_ICALL                                         $18     
         33        SEND_VAR                                                 $18
         34        DO_ICALL                                         $19     
         35        ASSIGN                                                   !3, $19
    8    36        INIT_FCALL                                               'preg_split'
         37        SEND_VAL                                                 '%23%28%3F%3C%3D%5Cd%29%28%3F%3D%5Ba-z%5D%29%23i'
         38        SEND_VAR                                                 !3
         39        DO_ICALL                                         $21     
         40        ASSIGN                                                   !4, $21
    9    41        FETCH_DIM_R                                      ~23     !4, 0
         42        ASSIGN                                                   !5, ~23
   10    43        FETCH_DIM_R                                      ~25     !4, 1
         44        ASSIGN                                                   !6, ~25
   11    45        IS_SMALLER                                       ~27     !5, 1
         46      > JMPZ_EX                                          ~27     ~27, ->64
         47    >   INIT_FCALL                                               'trim'
         48        INIT_FCALL                                               'strtolower'
         49        SEND_VAR                                                 !6
         50        DO_ICALL                                         $28     
         51        SEND_VAR                                                 $28
         52        DO_ICALL                                         $29     
         53        IS_EQUAL                                         ~30     $29, 'km'
         54      > JMPNZ_EX                                         ~30     ~30, ->63
         55    >   INIT_FCALL                                               'trim'
         56        INIT_FCALL                                               'strtolower'
         57        SEND_VAR                                                 !6
         58        DO_ICALL                                         $31     
         59        SEND_VAR                                                 $31
         60        DO_ICALL                                         $32     
         61        IS_EQUAL                                         ~33     $32, 'kms'
         62        BOOL                                             ~30     ~33
         63    >   BOOL                                             ~27     ~30
         64    > > JMPZ                                                     ~27, ->73
   12    65    >   MUL                                              ~34     !5, 1000
         66        ASSIGN                                                   !5, ~34
   13    67        ASSIGN                                                   !6, 'm'
   14    68        CONCAT                                           ~38     !5, '+'
         69        CONCAT                                           ~39     ~38, !6
         70        ASSIGN_DIM                                               !2, 'distance'
         71        OP_DATA                                                  ~39
         72      > JMP                                                      ->77
   17    73    >   CONCAT                                           ~41     !5, '+'
         74        CONCAT                                           ~42     ~41, !6
         75        ASSIGN_DIM                                               !2, 'distance'
         76        OP_DATA                                                  ~42
   19    77    > > RETURN                                                   !2
         78*       JMP                                                      ->88
   22    79    >   INIT_FCALL                                               'explode'
         80        SEND_VAL                                                 '+'
         81        INIT_FCALL                                               'trim'
         82        SEND_VAR                                                 !0
         83        DO_ICALL                                         $43     
         84        SEND_VAR                                                 $43
         85        DO_ICALL                                         $44     
         86        ASSIGN                                                   !1, $44
   23    87      > RETURN                                                   !1
   25    88*     > RETURN                                                   null

End of function sepnamedist

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.55 ms | 1411 KiB | 28 Q