I had previously been using basename
to grab the last part of my URL however have noticed some issues if my URL contains parameters.
So if my URL is this: https://www.google.com/test-page/?utm_source=test
How would I pull test-page
from this?
I had previously been using basename
to grab the last part of my URL however have noticed some issues if my URL contains parameters.
So if my URL is this: https://www.google.com/test-page/?utm_source=test
How would I pull test-page
from this?
You split it by the / delimiter, and then take the fourth item
$link = 'https://www.google.com/test-page/?utm_source=test';
$split = explode('/', $link);
if(isset($split[3]))
{
echo $split[3];
}