AW: [PHP-DEV] Re: Keyword proposal: in

From: Date: Thu, 07 Feb 2002 16:47:02 +0000
Subject: AW: [PHP-DEV] Re: Keyword proposal: in
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-79551@lists.php.net to get a copy of this message
What about: if (in_array($var,array(1,2,99))) { // ... } With "this-was-my-first-tiny-posting-to-php-dev-greetings" to all of you Matthias > -----Ursprungliche Nachricht----- > Von: Daniel Lorch [mailto:daniel@lorch.cc] > Gesendet: Donnerstag, 7. Februar 2002 17:15 > An: Manuel Lemos > Cc: php-dev@lists.php.net > Betreff: Re: [PHP-DEV] Re: Keyword proposal: in > > > Hi, > > > 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) { // ... > > > switch($var) > > { > > case 1: > > case 2: > > case 99: > > } > > if(preg_match("'^1|2|99$'", $var)) { > // .. > } > > -- Daniel Lorch > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.dev (#79551) next »