通过多维数组的 PHP foreach 循环
2022-08-30 13:40:52
我有一个数组:
$arr_nav = array( array( "id" => "apple",
"url" => "apple.html",
"name" => "My Apple"
),
array( "id" => "orange",
"url" => "orange/oranges.html",
"name" => "View All Oranges",
),
array( "id" => "pear",
"url" => "pear.html",
"name" => "A Pear"
)
);
我想使用foreach循环来替换(它只允许我设置数字:
for ($row = 0; $row < 5; $row++)
能够显示相关数组值的和类.first
.last
编辑
我希望数据回显为:
<li id="' . $arr_nav[$row]["id"] . '"><a href="' . $v_url_root . $arr_nav[$row]["url"] . '" title="' . $arr_nav[$row]["name"] . '">"' . $arr_nav[$row]["name"] . '</a></li>' . "\r\n";
非常感谢您的快速回复。堆积溢出岩石!