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) return; /*else if (count($searchPath) == 1) { $array = $newValue; } $lookFor = array_shift($searchPath); if ($lookFor === null) { foreach ($array as &$value) { if (is_array($value)) deepReplace($searchPath, $newValue, $value); } } else if (is_array($array) && array_key_exists($lookFor, $array)) { deepReplace($searchPath, $newValue, $array[$lookFor]); }*/ var_dump($searchPath); } //print_r($data); deepReplace(array("element1", "subelement1"), "newValue", $data); //print_r($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W4fmF
function name:  (null)
number of ops:  7
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   27     1        INIT_FCALL                                               'deepreplace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 'newValue'
          4        SEND_REF                                                 !0
          5        DO_FCALL                                      0          
   28     6      > 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
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W4fmF
function name:  deepReplace
number of ops:  11
compiled vars:  !0 = $searchPath, !1 = $newValue, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        COUNT                                            ~3      !0
          4        IS_EQUAL                                                 ~3, 0
          5      > JMPZ                                                     ~4, ->7
    8     6    > > RETURN                                                   null
   22     7    >   INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   23    10      > RETURN                                                   null

End of function deepreplace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.68 ms | 1397 KiB | 16 Q