<?php
$arr = array(
0 => array(
0 => array(
'name' => 'test1',
'country' => 'abc'
),
1 => array(
'name' => 'test2',
'country' => 'xyz'
)
),
1 => array(
'name' => 'test3',
'country' => 'pqr'
),
2 => array(
0 => array(
'name' => 'test1',
'country' => 'abc'
),
1 => array(
'name' => 'test2',
'country' => 'xyz'
),
2 => array(
'name' => 'test1',
'country' => 'abc'
),
3 => array(
'name' => 'test2',
'country' => 'xyz'
)
),
3 => array(
'name' => 'test3',
'country' => 'pqr'
),
);
$new = [];
foreach($arr as $subarr){
$new = array_merge($new, $subarr);
}
var_dump($new);
- Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- array(8) {
[0]=>
array(2) {
["name"]=>
string(5) "test1"
["country"]=>
string(3) "abc"
}
[1]=>
array(2) {
["name"]=>
string(5) "test2"
["country"]=>
string(3) "xyz"
}
["name"]=>
string(5) "test3"
["country"]=>
string(3) "pqr"
[2]=>
array(2) {
["name"]=>
string(5) "test1"
["country"]=>
string(3) "abc"
}
[3]=>
array(2) {
["name"]=>
string(5) "test2"
["country"]=>
string(3) "xyz"
}
[4]=>
array(2) {
["name"]=>
string(5) "test1"
["country"]=>
string(3) "abc"
}
[5]=>
array(2) {
["name"]=>
string(5) "test2"
["country"]=>
string(3) "xyz"
}
}
preferences:
149.09 ms | 409 KiB | 5 Q