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"););

echo "<pre>";
foreach ($goods as $section => $items)
    foreach ($items as $key => $description)
        echo "$section:\t$key\t($description)<br>";
echo "</pre>";
4

1 回答 1

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 -->           ^

它会工作......

于 2013-03-19T13:39:04.980 回答