php - How to shorten `if-statement` -


i have if statement in foreach loop. condition 125 characters long. there other ways shorten this?

if ($col == 'foo' || $col == 'bar' || $col == 'baz' || $col == 'fubar' || $col == 'spam' || $col == 'eggs') {     continue; }  

note: sorry confusion on condition values guys, 'a', 'b', ... meant various strings.

store elements in single dimension array first, in case like:

$array = array('a','b','c','d','e','f'); 

then use php in built function in_array() check whether $col exists in array, in looks like:

in_array($col, $array); 

entire code:

$array = array('a','b','c','d','e','f'); if(in_array($col, $array)) {     continue; } 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -