-1

Hi there my current code looks like this:

if (stripos($_SERVER['REQUEST_URI'],'cake') !== false) 
        {echo '<div class="clear"></div><a href="http://www.example.com/cakes/" class="btn"> >> View all Cakes</a>';}

This works well to check if the current URL contains the word 'cake' and Then display a link to all cakes.

What I need to add to this is:

If URL contains 'cake' but does not contain 'carrot' Then display a link to all cakes.

Any ideas on how I can modify?

Many Thanks

Stew
  • 3
  • 3

2 Answers2

1

Just add one more condition:

if (stripos($_SERVER['REQUEST_URI'],'cake') !== false && stripos($_SERVER['REQUEST_URI'],'carrot') === false) {
    echo '<div class="clear"></div><a href="http://www.example.com/cakes/" class="btn"> >> View all Cakes</a>';
}
Vladimir Gilevich
  • 861
  • 1
  • 10
  • 17
0

You can try the below code :

if (stripos($_SERVER['REQUEST_URI'],'cake') == true && stripos($_SERVER['REQUEST_URI'],'carrot') == false) 
        {echo '<div class="clear"></div><a href="http://www.example.com/cakes/" class="btn"> >> View all Cakes</a>';}
Happy Coding
  • 2,517
  • 1
  • 13
  • 24