3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrayName1 = array( '0' => array('name' => 'steve' ,'age' =>51 ) , '1' => array('name' => 'john' ,'age' =>48 ) , ); $arrayName2 = array( '0' => array('name' => 'Steve' ,'place' =>'downtown' ), '1' => array('name' => 'John' ,'place' =>'New York' ), ); $names2 = array_map('strtolower', array_column($arrayName2, 'name')); $output = array(); foreach ($arrayName1 as $array) { $key = array_search($array['name'], $names2); if ($key !== false) { $output[] = $array + $arrayName2[$key]; } else { $output[] = $array; } } print_r($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 30
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 30
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/m9M7d
function name:  (null)
number of ops:  35
compiled vars:  !0 = $arrayName1, !1 = $arrayName2, !2 = $names2, !3 = $output, !4 = $array, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   13     2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 'strtolower'
          4        INIT_FCALL                                               'array_column'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 'name'
          7        DO_ICALL                                         $8      
          8        SEND_VAR                                                 $8
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !2, $9
   14    11        ASSIGN                                                   !3, <array>
   15    12      > FE_RESET_R                                       $12     !0, ->30
         13    > > FE_FETCH_R                                               $12, !4, ->30
   16    14    >   INIT_FCALL                                               'array_search'
         15        FETCH_DIM_R                                      ~13     !4, 'name'
         16        SEND_VAL                                                 ~13
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $14     
         19        ASSIGN                                                   !5, $14
   17    20        TYPE_CHECK                                  1018          !5
         21      > JMPZ                                                     ~16, ->27
   18    22    >   FETCH_DIM_R                                      ~18     !1, !5
         23        ADD                                              ~19     !4, ~18
         24        ASSIGN_DIM                                               !3
         25        OP_DATA                                                  ~19
   17    26      > JMP                                                      ->29
   21    27    >   ASSIGN_DIM                                               !3
         28        OP_DATA                                                  !4
   15    29    > > JMP                                                      ->13
         30    >   FE_FREE                                                  $12
   24    31        INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.31 ms | 1014 KiB | 17 Q