Click to See Complete Forum and Search --> : Return if string is in an array


The_Wanderer
05-14-2007, 05:09 PM
Hey I need a simple function to determine if a given string is contained in an array

For Instance:
$findInMe = Array('SOLD OUT', 'ERROR', 'EXPIRED', 'NO DEAL');
$givenString = somethingFromMyDatabase;

If $givenString was found in $findInMe then the function would return true

Anybody know how to do this?

Thanks,
I appreciate it!

Taschen
05-14-2007, 05:27 PM
PHP has just the function - in_array($needle, array $haystack) @ http://www.php.net/in_array

The_Wanderer
05-14-2007, 05:30 PM
thats was ridiculously simple, thanks!