Compare multiple values in PHP

Place the values in an array, then use the function in_array() to check if they exist.

$checkVars = array(3, 4, 5, "string", "2010-05-16");
if(in_array($var, $checkVars)){
    // Value is found.
}

http://uk.php.net/manual/en/function.in-array.php

Leave a Comment