The php-in-array tag has no wiki summary.
38
votes
7answers
32k views
in_array() and multidimensional array
I use in_array() to check whether a value exists in an array like below,
$a = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $a))
{
echo "Got Irix";
}
//print_r($a);
but what about ...
7
votes
5answers
3k views
Which is faster: in_array() or a bunch of expressions in PHP?
Is it faster to do the following:
if ($var != 'test1' && $var != 'test2' && $var != 'test3' && $var != 'test4') { ... }
Or:
if (!in_array($var, array('test1', 'test2', ...