echo $_POST["name"]; //returns the value a user typed into the "name" field
我希望能够返回密钥的文本。在这个例子中,我想返回文本“name”。我可以这样做吗?
答案 0 :(得分:28)
$ _ POST只是一个普通的关联数组,所以你也可以循环遍历整个事情:
foreach($_POST as $key=>$value)
{
echo "$key=$value";
}
答案 1 :(得分:17)
检查array_keys()函数,假设这是PHP。
答案 2 :(得分:5)
@Tim:缺少)
。所以它应该是:
while( list( $field, $value ) = each( $_POST )) {
echo "<p>" . $field . " = " . $value . "</p>\n";
}
答案 3 :(得分:3)
while( list( $field, $value ) = each( $_POST )) {
echo "<p>" . $field . " = " . $value . "</p>\n";
}
答案 4 :(得分:0)
array_keys($_POST)
答案 5 :(得分:0)
foreach($_POST as $rvar)
{
$rvarkey=key($_POST)
$$rvarkey=mysql_real_escape_string($rvar);
}
it creates variables having the name of the request parameters which is pretty awesome.