Hello Reader in this blog you will see how to get result of two arrays in a single array using PHP
Array one name information
Array
(
[0] => Array
(
[0] => 125479
[1] => "Ankit"
[2] => "India"
)
[1] => Array
(
[0] => 0022547
[1] => "Jack"
[2] => "USA"
)
)
Array two have details
Array
(
[name] => Array
(
[0] => "Delhi"
[1] => "Washington DC"
)
)
Now the function below wil merge them into a single two dimensional array
$i=0;
$NewArray = array();
foreach($OriginalArray as $value) {
$NewArray[] = array_merge($value,array($_FILES['Upload']['name'][$i]));
$i++;
}
Output:-
Array
(
[0] => Array
(
[0] => 125479
[1] => "Ankit"
[2] => "India"
[3] => "Delhi"
)
[1] => Array
(
[0] => 0022547
[1] => "Jack"
[2] => "USA"
[3] => "Washington DC"
)
)
Now in the output you can see both the arrays have been merged. The key index of 0 of first array is 125479 and Ankit now the India is also added on the same key, Which was in the index of 0 of second array. Similarly you can easily merge all other index values into one single array.
0 Comment(s)