Re: Short writage of clauses

From: Date: Mon, 12 Jun 2006 10:04:57 +0000
Subject: Re: Short writage of clauses
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-237790@lists.php.net to get a copy of this message
Stut wrote: > Barry wrote: >> Well i do know that you can write IF as ( ? : ) but what i am asking >> about is something like this: >> >> if (a = 1 OR a = 2) > > I think you mean == not =. > >> is it anyway possible to write it like: >> if (a = 1 OR 2) >> >> I know this is wrong because "2" will always be true ... >> >> Any infos on that would be nice :) > > The only way I know of to do this sort of thing would be... > > if (in_array($a, array(1, 2))) > > But it begs the question why you would want to do this? it's a handy way to white list data. e.g. if (in_array($_GET['yourarg'], $allowedValsForYourArg)) echo "nice arg dude"; (btw: no need to beg ;-) > > -Stut >

« previous php.general (#237790) next »