So I’ve read the section on php.net about array_search returning a non-Boolean false which can evaluate to 0 which is kind of stupid because it can also return a value of 0 as the key for the element being searched if the function actually returns a true. This makes it difficult to use in an if statement and I’m not sure how to go about it. I can’t use the equality (===) operator because I am not looking for a specific value, just a true value. Can anyone help me out?
Example of code that I am using:
[code=php]
if(isset($_GET[‘video’]) && !empty($_GET[‘video’]) && array_search($_GET[‘video’],$validVideos) >= 0) {
showVideo($_GET[‘video’]);
} else {
Where $validVideos is an array of all the possible valid values that $_GET[‘video’] is allowed to be. If $
I’ve already tried just using array_search($_GET[‘video’],$validVideos) as a statement itself to see if it evaluated to true, but it doesn’t. I’m quite stuck.