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

End of function splitstreetnamenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.32 ms | 1407 KiB | 22 Q