I have an variable called $vars
which contains an array that is submitted with form:
Array
(
[name] => Sample Name
[email] => test@test.com
[job_role] =>
[telephone_number] => telephone number
[comment] => comment
)
How can I check if job_role
index is containing a value?
I tried:
if (in_array('', $vars)){
echo "Job role can't be empty";
} else {
echo "Job role submitted";
}
But this works on the whole array and not only the job_role
index.
Also, I tried:
if (isset($vars['job_role'])){
echo "match found";
} else {
echo "nothing there";
}
But it was returning "match found" even when I didn't submit anything...
Why is isset()
always returning true?