3v4l.org

run code in 300+ PHP versions simultaneously
<?php $address = '5e Dorpsstraat 5-B'; $matchArr = array(); $matchesFound = preg_match('/(\d+)/', $address, $matchArr); if ($matchesFound === 0) { throw new TransactionValidationException('Could not find house number in address.'); } $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 . "\n"; print $houseNumber . "\n"; print $houseNumberAdd;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 58
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 58
filename:       /in/INRus
function name:  (null)
number of ops:  64
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'
          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        IS_IDENTICAL                                             !2, 0
          9      > JMPZ                                                     ~12, ->14
    7    10    >   NEW                                              $13     'TransactionValidationException'
         11        SEND_VAL_EX                                              'Could+not+find+house+number+in+address.'
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $13
    9    14    >   INIT_FCALL                                               'array_pop'
         15        FETCH_DIM_W                                      $15     !1, 0
         16        SEND_REF                                                 $15
         17        DO_ICALL                                         $16     
         18        ASSIGN                                                   !3, $16
   11    19        INIT_FCALL                                               'strrpos'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $18     
         23        ASSIGN                                                   !4, $18
   12    24        INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 0
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                         $20     
         29        ASSIGN                                                   !5, $20
   15    30        INIT_FCALL                                               'trim'
         31        SEND_VAR                                                 !5
         32        DO_ICALL                                         $22     
         33        ASSIGN                                                   !5, $22
   16    34        ASSIGN                                                   !6, null
   18    35        STRLEN                                           ~25     !0
         36        STRLEN                                           ~26     !3
         37        ADD                                              ~27     !4, ~26
         38        IS_SMALLER                                               ~27, ~25
         39      > JMPZ                                                     ~28, ->58
   19    40    >   INIT_FCALL                                               'substr'
         41        SEND_VAR                                                 !0
         42        STRLEN                                           ~29     !3
         43        ADD                                              ~30     !4, ~29
         44        SEND_VAL                                                 ~30
         45        DO_ICALL                                         $31     
         46        ASSIGN                                                   !6, $31
   20    47        ASSIGN                                                   !1, <array>
   22    48        INIT_FCALL                                               'preg_match'
         49        SEND_VAL                                                 '%2Fa-Z%2F'
         50        SEND_VAR                                                 !6
         51        SEND_REF                                                 !1
         52        DO_ICALL                                         $34     
         53        ASSIGN                                                   !7, $34
   23    54        IS_IDENTICAL                                             !7, 1
         55      > JMPZ                                                     ~36, ->58
   24    56    >   FETCH_DIM_R                                      ~37     !1, 0
         57        ASSIGN                                                   !6, ~37
   27    58    >   CONCAT                                           ~39     !5, '%0A'
         59        ECHO                                                     ~39
   28    60        CONCAT                                           ~40     !3, '%0A'
         61        ECHO                                                     ~40
   29    62        ECHO                                                     !6
         63      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.39 ms | 1400 KiB | 23 Q