3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{"language":"en","education":[{"unit":"e1","language":"en"}],"membership":[{"uei":"21","Uifed":"failed"}]}'; $arrayData = json_decode($json, true); $replacementData = array('membership' => array(array('Uifed' => 'success'))); $newArrayData = array_replace_recursive($arrayData, $replacementData); print_r($newArrayData); $replacementData = array('Uifed' => 'success'); array_walk_recursive($arrayData, function (&$value, $key) use ($replacementData) { $value = $replacementData[$key] ?? $value; }); print_r($arrayData);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZCXUq
function name:  (null)
number of ops:  26
compiled vars:  !0 = $json, !1 = $arrayData, !2 = $replacementData, !3 = $newArrayData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%22language%22%3A%22en%22%2C%22education%22%3A%5B%7B%22unit%22%3A%22e1%22%2C%22language%22%3A%22en%22%7D%5D%2C%22membership%22%3A%5B%7B%22uei%22%3A%2221%22%2C%22Uifed%22%3A%22failed%22%7D%5D%7D'
    4     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    5     6        ASSIGN                                                   !2, <array>
    6     7        INIT_FCALL                                               'array_replace_recursive'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !3, $8
    8    12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                                 
   10    15        ASSIGN                                                   !2, <array>
   11    16        INIT_FCALL                                               'array_walk_recursive'
         17        SEND_REF                                                 !1
         18        DECLARE_LAMBDA_FUNCTION                          ~12     [0]
         19        BIND_LEXICAL                                             ~12, !2
   13    20        SEND_VAL                                                 ~12
   11    21        DO_ICALL                                                 
   15    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
         25      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZCXUq
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $value, !1 = $key, !2 = $replacementData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   12     3        FETCH_DIM_IS                                     ~3      !2, !1
          4        COALESCE                                         ~4      ~3
          5        QM_ASSIGN                                        ~4      !0
          6        ASSIGN                                                   !0, ~4
   13     7      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.5 ms | 956 KiB | 17 Q