i have an array output like this :
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
)
)
)
now i want to display 2015-01-23 , 2015-01-14 , 2015-01-13 and then each inner contents
origin: india
origin: usa
origin: england , etc....
how i accomplish this.? i already tried recursive function like this , but this couldn't find solution
any help would be greatly appreciated
you don't need a recursion as your array is flat (only 1 deep)
I'm not sure what you want but:
foreach($array as $key=>$subarray)
{
echo $key;
foreach($array[$key] as $subarray)
{
echo "origin".$subarray["origin"];
}
}
this should work. If you just want to see for debug, use var_dump($array);
try this:
foreach($array as $innerArray){
foreach($innerArray as $result){
echo "origin: "." ".$result['orgdate']." ".$result['origin'];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.