【发布时间】:2015-07-06 10:24:13
【问题描述】:
我有一个这样的数组$testing:
Array (
[CUST_TYPE] =>
Array (
[0] => Family
[1] => Regular
[2] => Corporate
[3] => Premium )
[TOTAL_BALANCE] =>
Array (
[0] => 420946131.01
[1] => 41272033223.93
[2] => 38873647942.4
[3] => 10465337565.61 )
)
我需要将这个数组转换(打印)成这样的:
{
cust_type : Family,
balance : 420946131.01
},
{
cust_type : Regular ,
balance : 41272033223.93
},
and so on..
这里是我用的简单的foreach,但是只能打印cust_type或者balance
$cols = array_keys($testing);
foreach ($testing[$cols[1]] as $i => $j) {
echo '{cust_type : ' . $j .
', balance : ' . $<What should I print??> . '},';
}
请提供帮助。 谢谢。
【问题讨论】:
-
数组是否总是只包含 2 个子数组?
-
@Andrew 是的,数组总是只包含 2 个子数组