I have a post-variable that has to be checked whether it is empty or not. I look at the value of the variable like this:
print_r($_POST['arrayId']);
and it prints the expected value.
However if I do this:
if(!empty($_POST['arrayId'])) {
// some stuff
} else {
echo "f";
}
f is printed, and the code that should be executed isn’t. How is this possible?
do this instead, it will check if the key is present in the post array, regardless of the value. also works for
NULL,false,0and any other values which are treated as “empty” values…