3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ 0 => [ 'id' => 1, 'name' => 'Peter', ], 1 => [ 'id' => 2, 'name' => 'John', ] ]; $arr2 = [ 0 => [ 'id' => 1, 'surname' => 'Newman', ], 1 => [ 'id' => 2, 'surname' => 'Cena', ] ]; $finalArr = array_map(function($x) use ($arr2) { foreach($arr2 as $b) { if ($x["id"] === $b["id"]) { return array_merge($x, $b); } } return $x; }, $arr1); var_dump($finalArr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e9jRE
function name:  (null)
number of ops:  13
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $finalArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   25     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          4        BIND_LEXICAL                                             ~5, !1
   32     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !0
   25     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   34     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/e9jRE
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $x, !1 = $arr2, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   26     2      > FE_RESET_R                                       $3      !1, ->15
          3    > > FE_FETCH_R                                               $3, !2, ->15
   27     4    >   FETCH_DIM_R                                      ~4      !0, 'id'
          5        FETCH_DIM_R                                      ~5      !2, 'id'
          6        IS_IDENTICAL                                             ~4, ~5
          7      > JMPZ                                                     ~6, ->14
   28     8    >   INIT_FCALL                                               'array_merge'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $7      
         12        FE_FREE                                                  $3
         13      > RETURN                                                   $7
   26    14    > > JMP                                                      ->3
         15    >   FE_FREE                                                  $3
   31    16      > RETURN                                                   !0
   32    17*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.33 ms | 1003 KiB | 16 Q