3v4l.org

run code in 300+ PHP versions simultaneously
<?php $old = '{"4":{"deu":1, "eng":1, "fra":1}}'; $new = '{"4":{"deu":1, "eng":2}}'; $oldArray = json_decode($old,true); $newArray = json_decode($new,true); $finalArray =[]; foreach($oldArray as $key=>$value){ $finalArray[$key] = array_merge($value,$newArray[$key]); } print_r($finalArray); echo json_encode($finalArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/i0QLt
function name:  (null)
number of ops:  33
compiled vars:  !0 = $old, !1 = $new, !2 = $oldArray, !3 = $newArray, !4 = $finalArray, !5 = $value, !6 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%224%22%3A%7B%22deu%22%3A1%2C+%22eng%22%3A1%2C+%22fra%22%3A1%7D%7D'
    4     1        ASSIGN                                                   !1, '%7B%224%22%3A%7B%22deu%22%3A1%2C+%22eng%22%3A2%7D%7D'
    6     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !2, $9
    7     7        INIT_FCALL                                               'json_decode'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 <true>
         10        DO_ICALL                                         $11     
         11        ASSIGN                                                   !3, $11
   10    12        ASSIGN                                                   !4, <array>
   11    13      > FE_RESET_R                                       $14     !2, ->24
         14    > > FE_FETCH_R                                       ~15     $14, !5, ->24
         15    >   ASSIGN                                                   !6, ~15
   12    16        INIT_FCALL                                               'array_merge'
         17        SEND_VAR                                                 !5
         18        FETCH_DIM_R                                      ~18     !3, !6
         19        SEND_VAL                                                 ~18
         20        DO_ICALL                                         $19     
         21        ASSIGN_DIM                                               !4, !6
         22        OP_DATA                                                  $19
   11    23      > JMP                                                      ->14
         24    >   FE_FREE                                                  $14
   15    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                                 
   17    28        INIT_FCALL                                               'json_encode'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $21     
         31        ECHO                                                     $21
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.42 ms | 1396 KiB | 21 Q