3v4l.org

run code in 300+ PHP versions simultaneously
<?php function splitStreetNameNumber($str) { $str = trim($str); if (0 >= strlen($str)) { return false; } $t = preg_split('/[0-9]+/', $str); if (isset($t[0]) && (!isset($t[1]) || trim($t[1]) == '')) { return array( 'name' => trim($t[0]), 'num' => 0, ); } else { $num = str_replace($t[0], '', $str); return array( 'name' => trim($t[0]), 'num' => trim($num), ); } } $a = array( 'Karlstr. 2', 'Karl Straße 2d', 'Karlsplatz 14 a', 'Karlsplatz', ); foreach($a as $b) { $c = splitStreetNameNumber($b); print_r($c); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/g1b9k
function name:  (null)
number of ops:  13
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                   !0, <array>
   31     1      > FE_RESET_R                                       $4      !0, ->11
          2    > > FE_FETCH_R                                               $4, !1, ->11
   32     3    >   INIT_FCALL                                               'splitstreetnamenumber'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   33     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   31    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $4
   34    12      > RETURN                                                   1

Function splitstreetnamenumber:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
2 jumps found. (Code = 47) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 35
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 26
filename:       /in/g1b9k
function name:  splitStreetNameNumber
number of ops:  53
compiled vars:  !0 = $str, !1 = $t, !2 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
    5     5        STRLEN                                           ~5      !0
          6        IS_SMALLER_OR_EQUAL                                      ~5, 0
          7      > JMPZ                                                     ~6, ->9
    6     8    > > RETURN                                                   <false>
    8     9    >   INIT_FCALL                                               'preg_split'
         10        SEND_VAL                                                 '%2F%5B0-9%5D%2B%2F'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        ASSIGN                                                   !1, $7
    9    14        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !1, 0
         15      > JMPZ_EX                                          ~9      ~9, ->26
         16    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !1, 1
         17        BOOL_NOT                                         ~11     ~10
         18      > JMPNZ_EX                                         ~11     ~11, ->25
         19    >   INIT_FCALL                                               'trim'
         20        FETCH_DIM_R                                      ~12     !1, 1
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                         $13     
         23        IS_EQUAL                                         ~14     $13, ''
         24        BOOL                                             ~11     ~14
         25    >   BOOL                                             ~9      ~11
         26    > > JMPZ                                                     ~9, ->35
   11    27    >   INIT_FCALL                                               'trim'
         28        FETCH_DIM_R                                      ~15     !1, 0
         29        SEND_VAL                                                 ~15
         30        DO_ICALL                                         $16     
         31        INIT_ARRAY                                       ~17     $16, 'name'
   12    32        ADD_ARRAY_ELEMENT                                ~17     0, 'num'
         33      > RETURN                                                   ~17
         34*       JMP                                                      ->52
   16    35    >   INIT_FCALL                                               'str_replace'
         36        FETCH_DIM_R                                      ~18     !1, 0
         37        SEND_VAL                                                 ~18
         38        SEND_VAL                                                 ''
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $19     
         41        ASSIGN                                                   !2, $19
   18    42        INIT_FCALL                                               'trim'
         43        FETCH_DIM_R                                      ~21     !1, 0
         44        SEND_VAL                                                 ~21
         45        DO_ICALL                                         $22     
         46        INIT_ARRAY                                       ~23     $22, 'name'
   19    47        INIT_FCALL                                               'trim'
         48        SEND_VAR                                                 !2
         49        DO_ICALL                                         $24     
         50        ADD_ARRAY_ELEMENT                                ~23     $24, 'num'
         51      > RETURN                                                   ~23
   22    52*     > RETURN                                                   null

End of function splitstreetnamenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.21 ms | 1403 KiB | 22 Q