如何从此数组中获取数字和月份的值。
Array
(
[mane] => Riya
[id] => 70
[order] => Array
(
[details] => Array
(
[number] => 4112
[month] => March
)
)
)
这是我试过的代码
foreach($order as $row) {
echo $row['details']['number'];
echo $row['details']['month'];
}
答案 0 :(得分:1)
您缺少order
数组。
从
改变echo $row['details']['number'];
echo $row['details']['month'];
向
echo $row['order']['details']['number'];
echo $row['order']['details']['month'];
// ^ error was here.
答案 1 :(得分:1)
你可以这样做
foreach($order as $key => $value){
if( is_array($value) and !empty($value) ){
foreach($value as $k => $v){
printData($v['number']);
printData($v['month']);
}
}else{
printData($value);
}
}
答案 2 :(得分:1)
这是一个简单的解决方案:
foreach ($order['order'] as $key => $value)
{
echo $value['number']."<BR />";
echo $value['month']."<BR />";
}
以下是适合您的DEMO