Question by user1069269
I have a site and I would need to get one pages URL with PHP. The URL might be something
www.mydomain.com/thestringineed/ or it can
www.mydomain.com/thestringineed?data=1 or it can be
So it’s always the last string but I dont want to get anything after ?
Answer by TecBrat
You will use the parse_url function, then look at the path portion of the return.
$url='www.mydomain.com/thestringineed?data=1'; $components=parse_url($url); $mystring= end(explode('/',$components['path']));