3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ ['id'=> 1,'name'=>'John Sena', 'lastname'=>'Jonn'], ['id'=> 2,'name'=>'Rock', 'lastname'=>'Rock Sena'] ]; $array2 = [ ['id'=>1, 'company'=>'Warner Brother'], ['id'=>2, 'company'=>'Metro'],['id'=>'1', 'Address'=>'USA'] ]; foreach ($array2 as $a2) { foreach ($array1 as &$a1) { if ($a2['id'] == $a1['id']) { $a1 = array_merge($a1, $a2); } } } print_r($array1);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 125) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 126) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/QsEa8
function name:  (null)
number of ops:  23
compiled vars:  !0 = $array1, !1 = $array2, !2 = $a2, !3 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $6      !1, ->18
          3    > > FE_FETCH_R                                               $6, !2, ->18
   13     4    > > FE_RESET_RW                                      $7      !0, ->16
          5    > > FE_FETCH_RW                                              $7, !3, ->16
   14     6    >   FETCH_DIM_R                                      ~8      !2, 'id'
          7        FETCH_DIM_R                                      ~9      !3, 'id'
          8        IS_EQUAL                                                 ~8, ~9
          9      > JMPZ                                                     ~10, ->15
   15    10    >   INIT_FCALL                                               'array_merge'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !3, $11
   13    15    > > JMP                                                      ->5
         16    >   FE_FREE                                                  $7
   12    17      > JMP                                                      ->3
         18    >   FE_FREE                                                  $6
   20    19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.93 ms | 1071 KiB | 15 Q