Forum Moderators: coopster

Message Too Old, No Replies

if does not equal to

         

ahmed24

7:04 am on Aug 28, 2009 (gmt 0)

10+ Year Member



i'm using the following code to check if $test does not equal word:

if($test != "word"){

but what i want to do is use the same code to check that $test does not equal more than one words like word1 word2 word3 etc.

any ideas?

thanks

leadegroot

7:14 am on Aug 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$wordlist = array('word1', 'word2', 'word3');
if (in_array($test, $wordlist)) {
...

ie if 'word' is one of 'word1', 'word2', 'word3' ...

untested.
Does that sound like what you want?

penders

8:59 am on Aug 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Or...
if (!in_array($test, $wordlist)) {

...to negate the expression, ie. 'does not equal...'

nanat

9:18 am on Aug 28, 2009 (gmt 0)

10+ Year Member



if($test <> "word")?