Jump to content

if (variable LIKE value)??


saint959

Recommended Posts

I've found this quite useful:

 

http://en.wikibooks.org/wiki/Programming:PHP:if_structure

 

I haven't come across a LIKE param or an "in" (if x in ('a','b','c') with php. I've used multiple ORs (||).

 

If you find a LIKE or an IN, please post it here - or better still, PM me!

lol here is a solution for you:

 

if (in($x, "a,b,c")) {
     // processing here
}

function in($var, $vars) {
      $vars = explode($vars, ",");
      if (is_array($vars)) {
           foreach ($vars as $chk) {
                 if ($chk == $var) 
                      return true;
           }
      }

      return false;
}

 

When all else fails create your own solution.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.