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); var_dump($lookFor); /*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]); } } //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/GgrVN
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
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 18
filename:       /in/GgrVN
function name:  deepReplace
number of ops:  27
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    > > RETURN                                                   null
   13     7    >   INIT_FCALL                                               'array_shift'
          8        SEND_REF                                                 !0
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !3, $6
   14    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                                 
   20    14        TYPE_CHECK                                  128  ~9      !2
         15      > JMPZ_EX                                          ~9      ~9, ->18
         16    >   ARRAY_KEY_EXISTS                                 ~10     !3, !2
         17        BOOL                                             ~9      ~10
         18    > > JMPZ                                                     ~9, ->26
   21    19    >   INIT_FCALL_BY_NAME                                       'deepReplace'
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !1
         22        CHECK_FUNC_ARG                                           
         23        FETCH_DIM_FUNC_ARG                               $11     !2, !3
         24        SEND_FUNC_ARG                                            $11
         25        DO_FCALL                                      0          
   23    26    > > RETURN                                                   null

End of function deepreplace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.54 ms | 1390 KiB | 18 Q