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]); } } 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/PYC4a
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>
   24     1        INIT_FCALL                                               'print_r'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   26     4        INIT_FCALL                                               'deepreplace'
          5        SEND_VAL                                                 <array>
          6        SEND_VAL                                                 'newValue'
          7        SEND_REF                                                 !0
          8        DO_FCALL                                      0          
   27     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 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 30
Branch analysis from position: 18
2 jumps found. (Code = 125) Position 1 = 19, Position 2 = 28
Branch analysis from position: 19
2 jumps found. (Code = 126) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 42
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 34
Branch analysis from position: 12
filename:       /in/PYC4a
function name:  deepReplace
number of ops:  43
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, ->8
    8     6    > > RETURN                                                   null
          7*       JMP                                                      ->12
    9     8    >   COUNT                                            ~7      !0
          9        IS_EQUAL                                                 ~7, 1
         10      > JMPZ                                                     ~8, ->12
   10    11    >   ASSIGN                                                   !2, !1
   13    12    >   INIT_FCALL                                               'array_shift'
         13        SEND_REF                                                 !0
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !3, $10
   14    16        TYPE_CHECK                                    2          !3
         17      > JMPZ                                                     ~12, ->30
   15    18    > > FE_RESET_RW                                      $13     !2, ->28
         19    > > FE_FETCH_RW                                              $13, !4, ->28
   16    20    >   TYPE_CHECK                                  128          !4
         21      > JMPZ                                                     ~14, ->27
   17    22    >   INIT_FCALL_BY_NAME                                       'deepReplace'
         23        SEND_VAR_EX                                              !0
         24        SEND_VAR_EX                                              !1
         25        SEND_VAR_EX                                              !4
         26        DO_FCALL                                      0          
   15    27    > > JMP                                                      ->19
         28    >   FE_FREE                                                  $13
         29      > JMP                                                      ->42
   19    30    >   TYPE_CHECK                                  128  ~16     !2
         31      > JMPZ_EX                                          ~16     ~16, ->34
         32    >   ARRAY_KEY_EXISTS                                 ~17     !3, !2
         33        BOOL                                             ~16     ~17
         34    > > JMPZ                                                     ~16, ->42
   20    35    >   INIT_FCALL_BY_NAME                                       'deepReplace'
         36        SEND_VAR_EX                                              !0
         37        SEND_VAR_EX                                              !1
         38        CHECK_FUNC_ARG                                           
         39        FETCH_DIM_FUNC_ARG                               $18     !2, !3
         40        SEND_FUNC_ARG                                            $18
         41        DO_FCALL                                      0          
   22    42    > > RETURN                                                   null

End of function deepreplace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.09 ms | 1402 KiB | 18 Q