Re: The || Operator

From: Date: Sat, 24 May 2003 18:15:18 +0000
Subject: Re: The || Operator
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148860@lists.php.net to get a copy of this message
Well, you could put your words into an array and use in_array() or use a switch like someone suggested. The way you wrote your if, you are or'ing together 3 strings. ("few"||"some"||"one") is going to evaluate to true and then what you have left is ($you==true) which is not what you wanted. -Rasmus On Sat, 24 May 2003, zavaboy wrote: > *Sigh* > I thought there would be a better way... > Thanks anyway! > > "Rasmus Lerdorf" <rasmus@lerdorf.com> wrote in message > > news:Pine.LNX.4.44.0305241022420.1237-100000@thinkpad.lerdorf.com... > > if($you=="few" || $you=="some" || $you=="one") > > > > On Sat, 24 May 2003, zavaboy wrote: > > > $you = "some"; > > > if ($you == ("few" || "some" || "one")) { > > > echo "yes"; > > > }else{ > > > echo "no"; > > > } > > > > > > How can I make it print out "yes" if $you is equal to "few", > > > "some", or > > > "one"? > > > > > > > > > > > > > > > > > >

« previous php.general (#148860) next »