0

Possible Duplicate:
Compare multiple values in PHP

I want to do something like this

if($abc="asdf","sdfg","dfgh") {
echo "Something";
}

What should I do? Do I have to use seperate rules with || ?

Community
  • 1
  • 1
Sid
  • 1,255
  • 2
  • 22
  • 45

1 Answers1

6

You would use in_array() for such purposes:

if (in_array($abc, array('asdf', 'sdfdg', 'qweqe'))) {
    // something
}

The third parameter of in_array() can be used to perform strict type checks between the needle and each item of the haystack, similar to ===.

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309