我在 PHP 中设置了一个多维数组,如下所示:
$contents = array(
"Header1" => array(
"Section 1" => array (
"Description1",
"Notes1",
),
"Gap" => "Gap",
"Section 2" => array (
"Description2",
"Notes2",
),
"Gap" => "Gap",
"Section 3" => array (
"Description3",
"Notes3",
),
),
);
然后我循环遍历这个数组,如下所示:
foreach ($contents as $header => $section) {
foreach ($section as $title => $details) {
echo $title."<br>";
}
}
输出将是:
Section1
Gap
Section2
Section3
为什么没有显示第二个“Gap”?
谢谢