Jump to content

if statment, multiple conditions


Mr.Canuck

Recommended Posts

Hey everyone. The following script does everything it is supposed to, but I want to add a few more "conditions" to the code.

Present code that works:

<?php

$cpage = $_GET['cpage'];

$cpage_list = array('intro', 'directions', 'hours', 'jam', 'pointe', 'about', 'tc', 'privacy'); 

if (!in_array($cpage, $cpage_list) && $_GET['xlspg'] !='contact_us')
{
    echo "<div id=\"bcrumbs\">" . $this->crumbTrail->Render() . "</div>";
}

?>

 

I want to add a few more xlspg pages to the condition. The

&& $_GET['xlspg'] !='contact_us')

works for the contact_us page and I want to add xlspg=cart, xlspg=msg etc. I thought maybe doing something like this:

&& $_GET['xlspg'] !='contact_us') && (!='cart') && (!='msg');

would work, but it does not.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/200322-if-statment-multiple-conditions/
Share on other sites

Conditions like the one you tried to make are a little tedious, its better just to use something like:

 

if (!in_array($cpage, $cpage_list) && $_GET['xlspg'] !='contact_us' && $_GET['xlspg'] !='cart' && $_GET['xlspg'] !='msg')

 

This *might* work:

if (!in_array($cpage, $cpage_list) && $_GET['xlspg'] != ('contact_us' || 'cart' || 'msg'))

 

-cb-

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.