0
$A = ["0" => "a", "1" => "b", "2" => "c"];
$B = ["0" => "aa", "1" => "bb", "2" => "cc"]
array_walk($A,function($item) use($B){
     $temp[] = $item;
     $temp[] = $B[?];
});

how to fill the ? above? how to get the current index in array_walk?

Jin Aazoe
  • 115
  • 1
  • 1
  • 9

1 Answers1

3

If I understood correctly something like that would work

$A = ["0" => "a", "1" => "b", "2" => "c"];
$B = ["0" => "aa", "1" => "bb", "2" => "cc"]
array_walk($A,function($item, $key) use($B){
     $temp[] = $item;
     $temp[] = $B[$key];
});
Matthieu
  • 948
  • 8
  • 8