Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple PHP Condition help: if($Var1 = in list($List) and $Cond2) - Is this posslbe?

Is this a possible function?

I need to check if a variable is existent in a list of ones I need to check against and also that cond2 is true eg

if($row['name'] == ("1" || "2" || "3") && $Cond2){
    doThis();
}

It's not working for me and all I changed in the copy paste was my list and the variable names

like image 438
Supernovah Avatar asked May 26 '09 14:05

Supernovah


1 Answers

if(in_array($row['name'], array('1', '2', '3')) && $Cond2) {
  doThis();
}

PHP's in_array() docs: http://us.php.net/manual/en/function.in-array.php

like image 65
ceejayoz Avatar answered Oct 20 '22 00:10

ceejayoz