1

我正在尝试使用这样的关联数组构建 url 查询:

http://website.com/go.php?status=0&day=monday

这是我的代码,但它只返回单词数组。

$status = $_GET["status"];

$day= $_GET["day"] = array(
    "monday" => "one",
    "tuesday" => "two",
);

echo $status . " " . $day;
4

1 回答 1

3

用作$_GET['day']数组的键:

$days = array("monday" => "one", "tuesday" => "two");

// Test if your array $day contains a key
// equivalent to the value in $_GET
// (only if $_GET['day'] was passed in the first place)
if (isset($_GET['day'] && isset($days[$_GET['day']])) {
  echo $status . " " . $days[$_GET['day']];
}
else echo "No such day...";
于 2012-06-30T20:08:52.547 回答