$products = array(
'paper' => "Paper Section" => array
(
'copier' => "Copier and Multipurpose",
'inkjet' => "Inkjet Printer",
),
'pens' => "Pen Section" => array
(
'ball' => "Ballpoint Pens",
'hilite' => "Highlighters"
),
'misc' => "Miscellaneous Section" => array
(
'tape' => "Sticky Tape",
'glue' => "Adhesive"
)
);
echo "<pre>";
foreach ($products as $section => $items)
foreach ($items as $key => $value)
echo "$section:\t$key\t($value)<br />";
echo "</pre>";
显然,我在这里要做的是将索引分配给 $section 集,而我在尝试这样做时遇到了错误。有没有其他方法可以做到这一点,或者在 PHP 中是不可能的?