views:

24

answers:

1

This is probably a simple answer, but I was curious if you have php code like say this:

if($_SESSION['id'] == '000001' || $_SESSION['id'] == '000002') {

Could those values be grouped somehow? My thoughts would be something like:

if($_SESSION['id'] == ('000001' || '000002')) {

Not a huge deal, just wondering if it is possible. If not, it seems like it should be.

+2  A: 

It is kind of possible using in_array():

if (in_array($_SESSION['id'], array("000001", "000002")))

or alternatively using switch:

switch ($_SESSION["id"])
 {
   case "000001":
   case "000002":
    // do something
   break;

   default:
   break;
 }
Pekka
+1 because I like in_array :)
middus