I want to know the best way to do a PHP IF OR statement.. but I have a list of arrays over 30+
This is the current format of the array:
if($cq=="45" || $cq=="45" || $cq=="35") {
// action to my function
}
I know I can do an array but Array(); does not support conditions..
Thanks
UPDATE - I know it is old, even I know that and I am novice PHP. Look at my profile questions example (blank ones)
This is the code I was left with:
if(
$cq=="45" ||
$cq=="53" ||
$cq=="37" ||
$cq=="70" || //
$cq=="74" || //
$cq=="36" || // - this function removes colours if they have this ID
$cq=="66" || //
$cq=="61" || //
$cq=="69" ||
$cq=="20" ||
$cq=="55" ||
$cq=="50")
{
}
$yourArray = ('45', '45', '35'):
if ( in_array($ca, $yourArray) ) { ... }
You can try with:
$cqs = array("45", "35");
if ( in_array($cq, $cqs) ) {
// action to your function
}
Also you have to concider your variable type - is it integer ? Then remove all of that "
You do this with array's:
$test = array(45,35);
if(in_array($cq,$test)){
// action to your function
}