我正在尝试输出多维数组中的所有数据,但是当我在浏览器中运行它时,我一直收到未知错误。据我所知,我做的一切都是正确的。我也玩过单引号和双引号,但仍然没有运气。希望一双新鲜的眼睛可以制造出一些东西。
$goods = array(
'foods' => array(
"desert" => "chocolate cake",
"fruit" => "fuji apples",
"veggies" => "baby carrots",
"poultry" => "grilled chicken"),
'drinks' => array(
"soda" => "coca cola",
"juice" => "florida orange",
"coffee" => "black",
"beer" => "heineken"););
echo "<pre>";
foreach ($goods as $section => $items)
foreach ($items as $key => $description)
echo "$section:\t$key\t($description)<br>";
echo "</pre>";
答案 0 :(得分:1)
$goods = array(
'foods' => array(
"desert" => "chocolate cake",
"fruit" => "fuji apples",
"veggies" => "baby carrots",
"poultry" => "grilled chicken"),
'drinks' => array(
"soda" => "coca cola",
"juice" => "florida orange",
"coffee" => "black",
"beer" => "heineken"););
//REMOVE THAT SEMICOLON --> ^
它会起作用......