我需要这个结果:
breakfast: Monday, Tuesday, Thursday
lunch: Monday, Saturday
dinner: Tuesday, Sunday
从这个阵列:
Array
(
[breakfast] => Array
(
[0] => Monday
[1] => Tuesday
[2] => Thursday
)
[lunch] => Array
(
[0] => Monday
[1] => Saturday
)
[dinner] => Array
(
[0] => Tuesday
[1] => Sunday
)
)
我该怎么办?
答案 0 :(得分:1)
试试这个,请注意数组初始化的语法错误
$a = Array
(
[breakfast] => Array
(
[0] => Monday
[1] => Tuesday
[2] => Thursday
)
[lunch] => Array
(
[0] => Monday
[1] => Saturday
)
[dinner] => Array
(
[0] => Tuesday
[1] => Sunday
)
);
foreach($a as $key => $val){
echo $key . " : " . implode(",",$val)."<br>";
}
答案 1 :(得分:0)
试试这个:
foreach($array as $key => $value){
echo $key . ' : ' . implode(',',$value) .'<br />';
}