PHP 如何转换关联数组?
PHP How to transform an associative array?
我有一个数组,它来自 POST 数据
Array
(
[date_from] => Array
(
[0] => 01/10/2015
...
)
[date_to] => Array
(
[0] => 01/11/2015
...
)
[price_eur] => Array
(
[0] => 8
...
)
[price_usd] => Array
(
[0] => 9
...
)
)
我想将其转换为:
Array
(
[0] => Array
(
['date_from'] => 01/10/2015
['date_to'] => 01/11/2015
['price_eur'] => 8
['price_usd'] => 9
)
...
)
如何转换这个php关联数组?
只是写意而已。让我知道进展如何
foreach ($original as $key => $arr){
foreach ($arr as $x => $y){
$new[$x][$key] = $y
}
}
我有一个数组,它来自 POST 数据
Array
(
[date_from] => Array
(
[0] => 01/10/2015
...
)
[date_to] => Array
(
[0] => 01/11/2015
...
)
[price_eur] => Array
(
[0] => 8
...
)
[price_usd] => Array
(
[0] => 9
...
)
)
我想将其转换为:
Array
(
[0] => Array
(
['date_from'] => 01/10/2015
['date_to'] => 01/11/2015
['price_eur'] => 8
['price_usd'] => 9
)
...
)
如何转换这个php关联数组?
只是写意而已。让我知道进展如何
foreach ($original as $key => $arr){
foreach ($arr as $x => $y){
$new[$x][$key] = $y
}
}