我的多维数组正在工作。但是通过调用时我似乎无法使用explode
或in_array
限制数组$_GET
<?
$shop = array(
array("red", "black", "blue", "green"),
array("orange"),
array("orange", "black"),
array("pink", "yellow")
);
foreach ($shop as $rowNumber => $row)
{
echo "<li><b>The row number $rowNumber</b>";
echo "<ul>";
foreach ($row as $col) {
if (in_array($col, explode(' and ', $_GET['filter']))){
echo "<li>".$col."</li>";
}
}
echo "</ul>";
echo "</li>";
}
?>
如果我运行脚本,$_GET["filter"]=="black"
它会显示所有项目 - 它应该只显示两个,例如这是错误的:其他行不应该出现:
应该是这个