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); $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/BZA8p
function name:  (null)
number of ops:  13
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   23     1      > FE_RESET_R                                       $4      !0, ->11
          2    > > FE_FETCH_R                                               $4, !1, ->11
   24     3    >   INIT_FCALL                                               'splitstreetnamenumber'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   25     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   23    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $4
   26    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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BZA8p
function name:  splitStreetNameNumber
number of ops:  32
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        INIT_FCALL                                               'str_replace'
         15        FETCH_DIM_R                                      ~9      !1, 0
         16        SEND_VAL                                                 ~9
         17        SEND_VAL                                                 ''
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $10     
         20        ASSIGN                                                   !2, $10
   11    21        INIT_FCALL                                               'trim'
         22        FETCH_DIM_R                                      ~12     !1, 0
         23        SEND_VAL                                                 ~12
         24        DO_ICALL                                         $13     
         25        INIT_ARRAY                                       ~14     $13, 'name'
   12    26        INIT_FCALL                                               'trim'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                         $15     
         29        ADD_ARRAY_ELEMENT                                ~14     $15, 'num'
         30      > RETURN                                                   ~14
   14    31*     > RETURN                                                   null

End of function splitstreetnamenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.75 ms | 1403 KiB | 22 Q