I’m currently using the following code to generate an active state on links:
<?php if ($_SERVER["REQUEST_URI"] == "/styles/bracelets.html/"):?>
Followed by an else if statement.
How would I add a wild card so that the path above includes all pages with a path of: /styles/bracelets.html?p=2, /styles/bracelets.html?p=3 etc.
Thanks in advance
Sam
You could use strpos() in this case:
This basically checks to make sure
/styles/bracelets.html/is at the beginning of the request URI and will also pass if there is additional content trailing the/on the end.strposwill return false if the need is not found in haystack, or 0 if it is found at the beginning of the haystack hence the need for===.preg_match() would also work, but strpos does the trick in this case.