我有一个像这样的数组输出:
Array
(
[2015-01-23] => Array
(
[0] => Array
(
[orgdate] => 2015-01-23
[origin] => india
)
[1] => Array
(
[orgdate] => 2015-01-23
[origin] => us
)
[2] => Array
(
[orgdate] => 2015-01-23
[origin] => england
)
[3] => Array
(
[orgdate] => 2015-01-23
[origin] => india2
)
[4] => Array
(
[orgdate] => 2015-01-23
[origin] => uae
)
[5] => Array
(
[orgdate] => 2015-01-23
[origin] => africa
)
[6] => Array
(
[orgdate] => 2015-01-23
[origin] => china
)
[7] => Array
(
[orgdate] => 2015-01-23
[origin] => hongkong
)
[8] => Array
(
[orgdate] => 2015-01-23
[origin] => africa2
)
[9] => Array
(
[orgdate] => 2015-01-23
[origin] => africa3
)
[10] => Array
(
[orgdate] => 2015-01-23
[origin] => africa4
)
[11] => Array
(
[orgdate] => 2015-01-23
[origin] => africa5
)
)
[2015-01-14] => Array
(
[0] => Array
(
[orgdate] => 2015-01-14
[origin] => japan1
)
[1] => Array
(
[orgdate] => 2015-01-14
[origin] => japan2
)
[2] => Array
(
[orgdate] => 2015-01-14
[origin] => japan3
)
[3] => Array
(
[orgdate] => 2015-01-14
[origin] => japan4
)
)
[2015-01-13] => Array
(
[0] => Array
(
[orgdate] => 2015-01-13
[origin] => russia
)
)
)
现在我要显示2015-01-23,2015-01-14,2015-01-13,然后是每个内部内容
origin: india
origin: usa
origin: england , etc....
我是如何实现这一目标的。我已经尝试了像this这样的递归函数,但是这找不到解决方案
任何帮助将不胜感激
答案 0 :(得分:3)
你不需要递归,因为你的数组是平的(只有1个深)
我不确定你想要什么,但是:
foreach($array as $key=>$subarray)
{
echo $key;
foreach($array[$key] as $subarray)
{
echo "origin".$subarray["origin"];
}
}
这应该有效。 如果您只想查看调试,请使用var_dump($ array);
答案 1 :(得分:1)
试试这个:
foreach($array as $innerArray){
foreach($innerArray as $result){
echo "origin: "." ".$result['orgdate']." ".$result['origin'];
}
}