3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ ["id" => 1, "data" => "data 1"], ["id" => 2, "data" => "data <4>"], ["id" => 3, "data" => "data 3"], ["id" => 4, "data" => "<3>"], ["id" => 5, "data" => "<2>"] ]; function recurse(&$array, $needle = null) { foreach ($array as ['id' => $id, 'data' => &$data]) { if (($needle ?? $id) === $id) { $data = preg_replace_callback( '/<(\d+)>/', fn($m) => recurse($array, (int) $m[1]), $data ); } if ($needle === $id) { return $data; } } } recurse($array); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IAp1r
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   25     1        INIT_FCALL                                                   'recurse'
          2        SEND_REF                                                     !0
          3        DO_FCALL                                          0          
   26     4        INIT_FCALL                                                   'var_export'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                                     
          7      > RETURN                                                       1

Function recurse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 27
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 27
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/IAp1r
function name:  recurse
number of ops:  29
compiled vars:  !0 = $array, !1 = $needle, !2 = $id, !3 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      null
   12     2      > FE_RESET_RW                                          $4      !0, ->27
          3    > > FE_FETCH_RW                                                  $4, $5, ->27
          4    >   FETCH_LIST_R                                         $6      $5, 'id'
          5        ASSIGN                                                       !2, $6
          6        FETCH_LIST_W                                         $8      $5, 'data'
          7        MAKE_REF                                             $9      $8
          8        ASSIGN_REF                                                   !3, $9
          9        FREE                                                         $5
   13    10        COALESCE                                             ~11     !1
         11        QM_ASSIGN                                            ~11     !2
         12        IS_IDENTICAL                                                 !2, ~11
         13      > JMPZ                                                         ~12, ->22
   14    14    >   INIT_FCALL                                                   'preg_replace_callback'
   15    15        SEND_VAL                                                     '%2F%3C%28%5Cd%2B%29%3E%2F'
   16    16        DECLARE_LAMBDA_FUNCTION                              ~13     [0]
         17        BIND_LEXICAL                                                 ~13, !0
         18        SEND_VAL                                                     ~13
   17    19        SEND_VAR                                                     !3
   14    20        DO_ICALL                                             $14     
         21        ASSIGN                                                       !3, $14
   20    22    >   IS_IDENTICAL                                                 !1, !2
         23      > JMPZ                                                         ~16, ->26
   21    24    >   FE_FREE                                                      $4
         25      > RETURN                                                       !3
   12    26    > > JMP                                                          ->3
         27    >   FE_FREE                                                      $4
   24    28      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IAp1r
function name:  {closure:recurse():16}
number of ops:  10
compiled vars:  !0 = $m, !1 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        INIT_FCALL_BY_NAME                                           'recurse'
          3        SEND_VAR_EX                                                  !1
          4        FETCH_DIM_R                                          ~2      !0, 1
          5        CAST                                              4  ~3      ~2
          6        SEND_VAL_EX                                                  ~3
          7        DO_FCALL                                          0  $4      
          8      > RETURN                                                       $4
          9*     > RETURN                                                       null

End of Dynamic Function 0

End of function recurse

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.21 ms | 1768 KiB | 16 Q