3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "23 St John Apt 92 rer 4, Wellington Country Block 5 No value test 54545 tt 232"; echo preg_replace_callback( '/\b(?:Ap(?:artmen)?t|Block|Department|Lot|Number|Villa)\s*\K\d{1,3}\b/i', fn($m) => sprintf('%04s', $m[0]), $str );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vsUjo
function name:  (null)
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '23+St+John+Apt+92+rer+4%2C+Wellington+Country+Block+5+No+value++test+54545+tt+232'
    5     1        INIT_FCALL                                               'preg_replace_callback'
    6     2        SEND_VAL                                                 '%2F%5Cb%28%3F%3AAp%28%3F%3Aartmen%29%3Ft%7CBlock%7CDepartment%7CLot%7CNumber%7CVilla%29%5Cs%2A%5CK%5Cd%7B1%2C3%7D%5Cb%2Fi'
    7     3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          4        SEND_VAL                                                 ~2
    8     5        SEND_VAR                                                 !0
    5     6        DO_ICALL                                         $3      
    8     7        ECHO                                                     $3
    9     8      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vsUjo
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'sprintf'
          2        SEND_VAL                                                 '%2504s'
          3        FETCH_DIM_R                                      ~1      !0, 0
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
          7*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.09 ms | 1011 KiB | 15 Q