3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array('element1' => array('subelement1'=>'value','subelement2'=>array('sub21'=>'hello')), 'element2'=>array('something'=>'this','subelement1'=>'awesome','subelement2'=>array('sub21'=>'world'))); function deepReplace($searchPath, $newValue, &$array) { if (count($searchPath) == 0) { $array = $newValue; } $lookFor = array_shift($searchPath); if ($lookFor === null) { var_dump($searchpath); foreach ($array as $value) { deepReplace($searchPath, $newValue, $value); } } else if (is_array($array) && array_key_exists($lookFor, $array)) { deepReplace($searchPath, $newValue, $array[$lookFor]); } } print_r($data); deepReplace(array(null, "subelement1"), "newValue", $data); print_r($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KoQVK
function name:  (null)
number of ops:  13
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'print_r'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   24     4        INIT_FCALL                                               'deepreplace'
          5        SEND_VAL                                                 <array>
          6        SEND_VAL                                                 'newValue'
          7        SEND_REF                                                 !0
          8        DO_FCALL                                      0          
   25     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function deepreplace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 38
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 30
Branch analysis from position: 7
filename:       /in/KoQVK
function name:  deepReplace
number of ops:  39
compiled vars:  !0 = $searchPath, !1 = $newValue, !2 = $array, !3 = $lookFor, !4 = $searchpath, !5 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        COUNT                                            ~6      !0
          4        IS_EQUAL                                                 ~6, 0
          5      > JMPZ                                                     ~7, ->7
    8     6    >   ASSIGN                                                   !2, !1
   11     7    >   INIT_FCALL                                               'array_shift'
          8        SEND_REF                                                 !0
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !3, $9
   12    11        TYPE_CHECK                                    2          !3
         12      > JMPZ                                                     ~11, ->26
   13    13    >   INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                                 
   14    16      > FE_RESET_R                                       $13     !2, ->24
         17    > > FE_FETCH_R                                               $13, !5, ->24
   15    18    >   INIT_FCALL_BY_NAME                                       'deepReplace'
         19        SEND_VAR_EX                                              !0
         20        SEND_VAR_EX                                              !1
         21        SEND_VAR_EX                                              !5
         22        DO_FCALL                                      0          
   14    23      > JMP                                                      ->17
         24    >   FE_FREE                                                  $13
         25      > JMP                                                      ->38
   17    26    >   TYPE_CHECK                                  128  ~15     !2
         27      > JMPZ_EX                                          ~15     ~15, ->30
         28    >   ARRAY_KEY_EXISTS                                 ~16     !3, !2
         29        BOOL                                             ~15     ~16
         30    > > JMPZ                                                     ~15, ->38
   18    31    >   INIT_FCALL_BY_NAME                                       'deepReplace'
         32        SEND_VAR_EX                                              !0
         33        SEND_VAR_EX                                              !1
         34        CHECK_FUNC_ARG                                           
         35        FETCH_DIM_FUNC_ARG                               $17     !2, !3
         36        SEND_FUNC_ARG                                            $17
         37        DO_FCALL                                      0          
   20    38    > > RETURN                                                   null

End of function deepreplace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.3 ms | 1403 KiB | 20 Q