I have two arrays that are inside foreach
loop, I want to merge them to one key and value.
let the first array "array1" inside foreach
:
$array1 = ['x', 'y', 'z'];
let the second array "array2" inside foreach
:
$array2 = ['a', 'b', 'c'];
Expected output should be as follows:
$mergeArray = [0=>['x', 'y', 'z','a', 'b', 'c']];
What I have done is the following:
$mergeArray = [];
foreach ($customer as $key => $value) {
$mergeArray[] = $value['items1'];
$mergeArray[] = $value['items2'];
echo '<pre>';
print_r($mergeArray);
exit;
}
Thanks and welcome all suggestions