Mr.Canuck Posted April 30, 2010 Share Posted April 30, 2010 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 More sharing options...
ChemicalBliss Posted May 1, 2010 Share Posted May 1, 2010 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- Link to comment https://forums.phpfreaks.com/topic/200322-if-statment-multiple-conditions/#findComment-1051316 Share on other sites More sharing options...
MidOhioIT Posted May 1, 2010 Share Posted May 1, 2010 I think you can also try this: && $_GET['xlspg'] !='contact_us') && ($_GET['xlspg']!='cart') && ($_GET['xlspg']!='msg'); Link to comment https://forums.phpfreaks.com/topic/200322-if-statment-multiple-conditions/#findComment-1051330 Share on other sites More sharing options...
Mr.Canuck Posted May 1, 2010 Author Share Posted May 1, 2010 Thanks for the replies guys. ChemicalBliss. I used your first example and it worked perfectly. Thanks!! Link to comment https://forums.phpfreaks.com/topic/200322-if-statment-multiple-conditions/#findComment-1051331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.