I'm looking for a way to display some code based on the URL of the site.
Case 1:
If url contains getting-started
do something
Case 2:
If url contains getting-started/*
(could be anything) show something else.
I'm currently getting the URL string as:
$url = $_SERVER['REQUEST_URI'];
And then performing strpos
if (strpos($slug,'getting-started')){
But I need something to specifically target URLs where the end is getting-started
and also be able to identify when there is more that comes after it.
You should use regex:
You could combine this with
preg_match()