这可能是数组,我想从中创建一个数组。
以下是我当前的数组,我希望数组在单个数组中。
Array
(
[0] => Array
(
[item_name1] => First Name
[quantity1] => 1
[mc_gross1] => 189.00
)
[1] => Array
(
[item_name2] => Last Name
[quantity2] => 1
[mc_gross2] => 22.00
)
[2] => Array
(
[item_name3] => Email Addres
[quantity3] => 3
[mc_gross3] => 21.00
)
)
我想要
Array
(
[item_name1] => First Name
[quantity1] => 1
[mc_gross1] => 189.00
[item_name2] => Last Name
[quantity2] => 1
[mc_gross2] => 22.00
[item_name3] => Email Addres
[quantity3] => 3
[mc_gross3] => 21.00
)
我试过以下方式,但我无法得到我想要的结果。
<?php
$result = array();
foreach($result as $inner) {
$result[key($inner)] = current($inner);
}
?>
有人请帮帮我,我怎么解决这个问题?
答案 0 :(得分:2)
尝试以下
<?php
$final_result = array();
foreach($result as $inner) {
$final_result = array_merge($final_result,$inner);
}
?>