3v4l.org

run code in 300+ PHP versions simultaneously
<?php $first_array = Array ( '0' =>Array ( 'id_person' => 194, 'firstname' =>'Jesper', 'lastname' =>'Hansen' , 'pos' => 29, 'position' => 1, 'starter' => 0, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '1' =>Array ( 'id_person' => 195, 'firstname' =>'Mikkel', 'lastname' =>'Andersen' , 'pos' => 1, 'position' => 1, 'starter' => 1, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '2' =>Array ( 'id_person' => 197, 'firstname' =>'Alexander', 'lastname' =>'Scholz' , 'pos' => 6, 'position' => 2, 'starter' => 1, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '3' =>Array ( 'id_person' => 198, 'firstname' =>'Erik', 'lastname' =>'Sviatchenko' , 'pos' => 10, 'position' => 2, 'starter' => 1, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '4' =>Array ( 'id_person' => 199, 'firstname' =>'Kian', 'lastname' =>'Hansen' , 'pos' => 14, 'position' => 2, 'starter' => 1, 'subs' => 0, 'goal' => null, 'yellow_card' => null, 'red_card' => null, ) , '5' =>Array ( 'id_person' => 204, 'firstname' =>'Manjrekar', 'lastname' =>'James' , 'pos' => 30, 'position' => 2, 'starter' => 0, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '6' =>Array ( 'id_person' => 236, 'firstname' =>'Sebastian', 'lastname' =>'Buch' , 'pos' => 14, 'position' => 14, 'starter' => 0, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '7' =>Array ( 'id_person' => 209, 'firstname' =>'Joel', 'lastname' =>'Andersson', 'pos' => 18, 'position' => 3, 'starter' => 1, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) ); $second_array = Array ( '0' => Array ( 'id_person' => 195, 'position' => 1, 'first' => 'Mikkel', 'last' => 'Andersen' , 'id_club' => 2, 'type' => 2, 'captain' => 0, 'pos' => 1, 'subsmin_in' => null, 'subsmin_out' => null, 'starter' => 1, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '1' => Array ( 'id_person' => 236, 'position' => 14, 'first' => 'Sebastian', 'last' => 'Buch' , 'id_club' => 2, 'type' => 2, 'captain' => 0, 'pos' => 14, 'subsmin_in' => null, 'subsmin_out' => null, 'starter' => 0, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) , '2' => Array ( 'id_person' => 209, 'position' => 3, 'first' => 'Joel', 'last' => 'Andersson' , 'id_club' => 2, 'type' => 2, 'captain' => 0, 'pos' => 18, 'subsmin_in' => null, 'subsmin_out' => null, 'starter' => 1, 'subs' => 0, 'goal' => 0, 'yellow_card' => null, 'red_card' => null, ) ); foreach($second_array as $k=>$v){ $id_person = $v['id_person']; $key = array_search($id_person, array_column($first_array, 'id_person')); if($key){ $second_array[$k]['starter'] = $first_array[$key]['starter']; $second_array[$k]['subs'] = $first_array[$key]['subs']; $second_array[$k]['yellow_card'] = $first_array[$key]['yellow_card']; $second_array[$k]['red_card'] = $first_array[$key]['red_card']; } } print_r($second_array); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 38
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 38
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 37
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 37
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/FeanU
function name:  (null)
number of ops:  43
compiled vars:  !0 = $first_array, !1 = $second_array, !2 = $v, !3 = $k, !4 = $id_person, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
  117     1        ASSIGN                                                   !1, <array>
  178     2      > FE_RESET_R                                       $8      !1, ->38
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->38
          4    >   ASSIGN                                                   !3, ~9
  179     5        FETCH_DIM_R                                      ~11     !2, 'id_person'
          6        ASSIGN                                                   !4, ~11
  180     7        INIT_FCALL                                               'array_search'
          8        SEND_VAR                                                 !4
          9        INIT_FCALL                                               'array_column'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 'id_person'
         12        DO_ICALL                                         $13     
         13        SEND_VAR                                                 $13
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !5, $14
  181    16      > JMPZ                                                     !5, ->37
  182    17    >   FETCH_DIM_R                                      ~18     !0, !5
         18        FETCH_DIM_R                                      ~19     ~18, 'starter'
         19        FETCH_DIM_W                                      $16     !1, !3
         20        ASSIGN_DIM                                               $16, 'starter'
         21        OP_DATA                                                  ~19
  183    22        FETCH_DIM_R                                      ~22     !0, !5
         23        FETCH_DIM_R                                      ~23     ~22, 'subs'
         24        FETCH_DIM_W                                      $20     !1, !3
         25        ASSIGN_DIM                                               $20, 'subs'
         26        OP_DATA                                                  ~23
  184    27        FETCH_DIM_R                                      ~26     !0, !5
         28        FETCH_DIM_R                                      ~27     ~26, 'yellow_card'
         29        FETCH_DIM_W                                      $24     !1, !3
         30        ASSIGN_DIM                                               $24, 'yellow_card'
         31        OP_DATA                                                  ~27
  185    32        FETCH_DIM_R                                      ~30     !0, !5
         33        FETCH_DIM_R                                      ~31     ~30, 'red_card'
         34        FETCH_DIM_W                                      $28     !1, !3
         35        ASSIGN_DIM                                               $28, 'red_card'
         36        OP_DATA                                                  ~31
  178    37    > > JMP                                                      ->3
         38    >   FE_FREE                                                  $8
  188    39        INIT_FCALL                                               'print_r'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                                 
  189    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.01 ms | 1012 KiB | 16 Q