Re: Keyword proposal: in
| From: | Markus Fischer | Date: | Wed, 06 Feb 2002 19:33:09 +0000 |
| Subject: | Re: Keyword proposal: in | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-79386@lists.php.net to get a copy of this message | ||
On Wed, Feb 06, 2002 at 05:25:15PM +0100, Alex Kiesel wrote :
> I'd like to propose a new keyword: in. It should work like the
> SQL-in-expression.
>
> For example you have a variable $val and want to test whether it
> contains e.g. 1 or 2 or 99.
>
> At the moment I would choose between on of the following
> code-constructs:
>
> 1.) if ($var == 1 ||
> $var == 2 ||
> $var == 99) { // ...
>
> 2.) if (in_array ($var, array (1, 2, 99)) { // ...
Methinks in_array() is exactly the way to do it and not way
else.
--
Please always Cc to me when replying to me on the lists.