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

End of function deepreplace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.17 ms | 1403 KiB | 18 Q