3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fixAddress($address) { $address = trim($address); $addr_words = str_word_count($address, 1, "/',.-$#@&*!+=0123456789"); $addr_line1 = ''; foreach ($addr_words as $word) { if(strlen($addr_line1.' '.$word) <= 30) { $addr_line1 .= ' '.$word; array_shift($addr_words); } else { break; } } $addr_line2 = ''; if(!empty($addr_words)) { $addr_line2 = substr(implode(' ', $addr_words), 0, 30); } return array('addr_line1'=>trim($addr_line1), 'addr_line2'=>trim($addr_line2)); } $t = fixAddress('201 12th Street South, South, $word'); print_r($t); exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/cmCRE
function name:  (null)
number of ops:  9
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'fixaddress'
          1        SEND_VAL                                                 '201+12th+Street++South%2C++South%2C+%24word'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   23     4        INIT_FCALL                                               'print_r'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   24     7      > EXIT                                                     
          8*     > RETURN                                                   1

Function fixaddress:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 27
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 42
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 27
Branch analysis from position: 27
filename:       /in/cmCRE
function name:  fixAddress
number of ops:  52
compiled vars:  !0 = $address, !1 = $addr_words, !2 = $addr_line1, !3 = $word, !4 = $addr_line2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !0, $5
    4     5        INIT_FCALL                                               'str_word_count'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 1
          8        SEND_VAL                                                 '%2F%27%2C.-%24%23%40%26%2A%21%2B%3D0123456789'
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !1, $7
    5    11        ASSIGN                                                   !2, ''
    6    12      > FE_RESET_R                                       $10     !1, ->27
         13    > > FE_FETCH_R                                               $10, !3, ->27
    7    14    >   CONCAT                                           ~11     !2, '+'
         15        CONCAT                                           ~12     ~11, !3
         16        STRLEN                                           ~13     ~12
         17        IS_SMALLER_OR_EQUAL                                      ~13, 30
         18      > JMPZ                                                     ~14, ->25
    8    19    >   CONCAT                                           ~15     '+', !3
         20        ASSIGN_OP                                     8          !2, ~15
    9    21        INIT_FCALL                                               'array_shift'
         22        SEND_REF                                                 !1
         23        DO_ICALL                                                 
         24      > JMP                                                      ->26
   11    25    > > JMP                                                      ->27
    6    26    > > JMP                                                      ->13
         27    >   FE_FREE                                                  $10
   14    28        ASSIGN                                                   !4, ''
   15    29        ISSET_ISEMPTY_CV                                 ~19     !1
         30        BOOL_NOT                                         ~20     ~19
         31      > JMPZ                                                     ~20, ->42
   16    32    >   INIT_FCALL                                               'substr'
         33        INIT_FCALL                                               'implode'
         34        SEND_VAL                                                 '+'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $21     
         37        SEND_VAR                                                 $21
         38        SEND_VAL                                                 0
         39        SEND_VAL                                                 30
         40        DO_ICALL                                         $22     
         41        ASSIGN                                                   !4, $22
   18    42    >   INIT_FCALL                                               'trim'
         43        SEND_VAR                                                 !2
         44        DO_ICALL                                         $24     
         45        INIT_ARRAY                                       ~25     $24, 'addr_line1'
         46        INIT_FCALL                                               'trim'
         47        SEND_VAR                                                 !4
         48        DO_ICALL                                         $26     
         49        ADD_ARRAY_ELEMENT                                ~25     $26, 'addr_line2'
         50      > RETURN                                                   ~25
   19    51*     > RETURN                                                   null

End of function fixaddress

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
202.21 ms | 1403 KiB | 26 Q