[英]How to unset a key on a $_POST array?
I have some code to intercept a POST request, and then based on the value of another key, to unset a different key. 我有一些代码可以拦截POST请求,然后根据另一个键的值来取消设置其他键。 However that part isn't working. 但是,该部分不起作用。
I know this is not the ideal method of doing this, but the script is an add-on to an existing open source platform, so I'm unable to modify existing scripts. 我知道这不是执行此操作的理想方法,但是该脚本是现有开放源代码平台的附加组件,因此我无法修改现有脚本。
if($_POST['id']['txt_10'] == "Initials"){
unset($_POST['id']['id[8]']);
}else if($_POST['id']['txt_10'] == "Name"){
unset($_POST['id']['id[1]']);
}
However this code doesn't do anything and doesn't even display an error. 但是,此代码不执行任何操作,甚至不显示错误。 Using a var_dump($_POST['id']);
使用var_dump($_POST['id']);
I can see the key is still set. 我可以看到密钥仍然设置。
-- -
This is the var_dump of the $_POST['id'] array: 这是$ _POST ['id']数组的var_dump:
array(7) {
["txt_10"]=> string(4) "Name"
["txt_11"]=> string(0) ""
[1]=> int(72)
[4]=> int(0)
[8]=> int(170)
["txt_7"]=> string(7) "wefgweg"
[5]=> int(0)
}
unset($_POST['id'][8])
将是正确的解决方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.