RE: [PHP-DEV] Function suggestion
| From: | Richard Heyes | Date: | Mon, 10 Jul 2000 13:56:48 +0000 |
| Subject: | RE: [PHP-DEV] Function suggestion | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-24075@lists.php.net to get a copy of this message | ||
> On Sun, 09 Jul 2000, Richard Heyes wrote:
> > Is this the correct place for it?
>
> Yes.
More of a language construct really, the IN() function that MySQL has,
as a shortcut for multiple ORs. Like so:
if($var IN('compare1', 'compare2', 'compare3')){
...blah...
}
Here's my (somewhat limited) php version of it...
function in($compare, $options, $seperator = ','){
$opt_array = explode($seperator, $options);
for($i=0; $i<count($opt_array); $i++) if($compare == $opt_array[$i])
return TRUE;
return FALSE;
}
Take care!
--
Richard Heyes
http://www.heyes-computing.net/scripts/