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

End of function deepreplace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.88 ms | 1394 KiB | 18 Q