我刚刚写了一个数组键,只返回以 $_POST 形式存在的确切键
function array_key_exists_exact($strkeys, $search)
{
$keys = split('\|',$strkeys);
foreach($keys as $key)
{
if(array_key_exists($key,$search))
{
$newkeys[$key]=$key;
unset($newkeys[$key]);
}
else
{
}
}
return $newkeys;
}
但是它正在返回所有密钥,我做错了什么。
例如:
$str="email|phone|address|school|country";
array_key_exists_exact($str, $_POST)
应该只返回基于 $str 的表单中包含的内容。
所以如果我的表格有:
<form>
<input type=text name=email>
<input type=text name=phone>
<input type=text name=address>
</form>
输出应该是:
array("email", "phone", "address")
现在它输出这个:array("email", "phone", "address", "school", "country").
是的,我必须通过$str="email|phone|address|school|country";