I'm trying to find out if a variable exists in an array. So far I've tried using isset($a,$b) to find out if $a exists in the array $b but I get the same result every time under both circumstances. I also tried using array_key_exists($a, $b) which also returned the same result. Any ideas how I can find out if a variable exists within an array?
With in_array($a, $b) you can enter a third value which seems to be boolean. Does this mean you can run this command so that if(in_array($a,$b,false)){ print "This was false";} would return This was false if a was not in b?
No, the third parameter defaults to FALSE. It's used to also check the data type. What do you mean by a variable existing in an array? The variable being a key in an array or an actual value?
The actual value. in_array seems to do the trick. For some reason I was under the impression that in_array searches for the pattern rather than an identical match.