3v4l.org

run code in 300+ PHP versions simultaneously
<?php $address = '5e Dorpsstraat 5-B'; $matchArr = array(); $matchesFound = preg_match_all('/(\d+)/', $address, $matchArr); $houseNumber = array_pop($matchArr[0]); // strrpos om problemen te voorkomen bij straatnamen zoals 151th Avenue 151 $houseNumberStartPos = strrpos($address, $houseNumber); $streetName = substr($address, 0, $houseNumberStartPos); // Verwijder whitespace bij correcte notatie, geen -1 op strrpos voor foute notatie. // Voorbeeld Dorpsstraat 12 (correct), Dorpsstraat12 (incorrect). $streetName = trim($streetName); $houseNumberAdd = NULL; // Check of er mogelijk een additie is op het huisnummer, zoals B of -A of w/e. if (strlen($address) > ($houseNumberStartPos + strlen($houseNumber))) { $houseNumberAdd = substr($address, ($houseNumberStartPos + strlen($houseNumber))); $matchArr = array(); // Filter alles dat niet alfa is uit de addition field. $matchFound = preg_match('/[a-Z]/', $houseNumberAdd, $matchArr); if ($matchFound === 1) { $houseNumberAdd = $matchArr[0]; } } print $streetName . " / "; print $houseNumber . " / "; print $houseNumberAdd;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 52
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
Branch analysis from position: 52
filename:       /in/o7RsL
function name:  (null)
number of ops:  58
compiled vars:  !0 = $address, !1 = $matchArr, !2 = $matchesFound, !3 = $houseNumber, !4 = $houseNumberStartPos, !5 = $streetName, !6 = $houseNumberAdd, !7 = $matchFound
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '5e+Dorpsstraat+5-B'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAL                                                 '%2F%28%5Cd%2B%29%2F'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !1
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !2, $10
    6     8        INIT_FCALL                                               'array_pop'
          9        FETCH_DIM_W                                      $12     !1, 0
         10        SEND_REF                                                 $12
         11        DO_ICALL                                         $13     
         12        ASSIGN                                                   !3, $13
    8    13        INIT_FCALL                                               'strrpos'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $15     
         17        ASSIGN                                                   !4, $15
    9    18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 0
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                         $17     
         23        ASSIGN                                                   !5, $17
   12    24        INIT_FCALL                                               'trim'
         25        SEND_VAR                                                 !5
         26        DO_ICALL                                         $19     
         27        ASSIGN                                                   !5, $19
   13    28        ASSIGN                                                   !6, null
   15    29        STRLEN                                           ~22     !0
         30        STRLEN                                           ~23     !3
         31        ADD                                              ~24     !4, ~23
         32        IS_SMALLER                                               ~24, ~22
         33      > JMPZ                                                     ~25, ->52
   16    34    >   INIT_FCALL                                               'substr'
         35        SEND_VAR                                                 !0
         36        STRLEN                                           ~26     !3
         37        ADD                                              ~27     !4, ~26
         38        SEND_VAL                                                 ~27
         39        DO_ICALL                                         $28     
         40        ASSIGN                                                   !6, $28
   17    41        ASSIGN                                                   !1, <array>
   19    42        INIT_FCALL                                               'preg_match'
         43        SEND_VAL                                                 '%2F%5Ba-Z%5D%2F'
         44        SEND_VAR                                                 !6
         45        SEND_REF                                                 !1
         46        DO_ICALL                                         $31     
         47        ASSIGN                                                   !7, $31
   20    48        IS_IDENTICAL                                             !7, 1
         49      > JMPZ                                                     ~33, ->52
   21    50    >   FETCH_DIM_R                                      ~34     !1, 0
         51        ASSIGN                                                   !6, ~34
   24    52    >   CONCAT                                           ~36     !5, '+%2F+'
         53        ECHO                                                     ~36
   25    54        CONCAT                                           ~37     !3, '+%2F+'
         55        ECHO                                                     ~37
   26    56        ECHO                                                     !6
         57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.02 ms | 1400 KiB | 25 Q