3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array( 'id' => 1, 'user_name'=>'test1' ), array( 'id' => 2, 'user_name'=>'test2' ), array( 'id' => 3, 'user_name'=>'test3' ) ); $arr2 = array( array( 'id' => 1, 'shop_name'=>'shop1' ), array( 'id' => 5, 'shop_name'=>'shop2' ), array( 'id' => 3, 'shop_name'=>'shop3' ) ); $shop_name = array_column($arr2, 'shop_name', 'id'); foreach($arr as $key => $item) { $exist = array_key_exists($item['id'], $shop_name); $arr[$key]['shop_name'] = $exist ? $shop_name[$item['id']] : ''; } print_r($arr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/V66Xa
function name:  (null)
number of ops:  29
compiled vars:  !0 = $arr, !1 = $arr2, !2 = $shop_name, !3 = $item, !4 = $key, !5 = $exist
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   16     1        ASSIGN                                                   !1, <array>
   31     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 'shop_name'
          5        SEND_VAL                                                 'id'
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !2, $8
   33     8      > FE_RESET_R                                       $10     !0, ->24
          9    > > FE_FETCH_R                                       ~11     $10, !3, ->24
         10    >   ASSIGN                                                   !4, ~11
   34    11        FETCH_DIM_R                                      ~13     !3, 'id'
         12        ARRAY_KEY_EXISTS                                 ~14     ~13, !2
         13        ASSIGN                                                   !5, ~14
   35    14      > JMPZ                                                     !5, ->19
         15    >   FETCH_DIM_R                                      ~18     !3, 'id'
         16        FETCH_DIM_R                                      ~19     !2, ~18
         17        QM_ASSIGN                                        ~20     ~19
         18      > JMP                                                      ->20
         19    >   QM_ASSIGN                                        ~20     ''
         20    >   FETCH_DIM_W                                      $16     !0, !4
         21        ASSIGN_DIM                                               $16, 'shop_name'
         22        OP_DATA                                                  ~20
   33    23      > JMP                                                      ->9
         24    >   FE_FREE                                                  $10
   38    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.05 ms | 1388 KiB | 17 Q