Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

if $variable !=('term1','term2','term3')

if $variable !=('term1','term2','term3')

is this the correct syntax
Avatar of Rik-Legger
Rik-Legger
Flag of undefined image

if ($variable != 'term1' OR $variable != 'term2' OR $variable != 'term3') {
    // 
}

Open in new window

if ($variable != 'term1' || $variable != 'term2' || $variable != 'term3') {
    //
}

|| is or
&& is and
Avatar of rgb192

ASKER

i have 100 terms
can I do a list or array
$array = array(
    'term1',
    'term2',
);

if (! in_array($variable, $array)) {
    //
}

Open in new window

$a = array('1.10', 12.4, 1.13);

if (in_array('12.4', $a, true)) {
    echo "'12.4' found with strict check\n";
}


http://php.net/manual/en/function.in-array.php
will go with enachemc, +1 for this...
Avatar of rgb192

ASKER

is there a way to do a for loop

because I would have to repeat myself in the if...
ASKER CERTIFIED SOLUTION
Avatar of Rik-Legger
Rik-Legger
Flag of undefined image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks