adam291086 Posted September 3, 2008 Share Posted September 3, 2008 i have this url /kunden/homepages/12/d214897219/htdocs/rubberduckiee/rubberduckiee/www.adamplowman.co.uk/random and i want to remove the last part of the url i.e random. and then replace with a variable called $foldername can anyone push me in the right directions? Link to comment https://forums.phpfreaks.com/topic/122506-solved-help-removing-last-part-of-a-url/ Share on other sites More sharing options...
Fadion Posted September 3, 2008 Share Posted September 3, 2008 Try this: <?php $url = "/kunden/homepages/12/d214897219/htdocs/rubberduckiee/rubberduckiee/www.adamplowman.co.uk/random"; $url = substr($url, 0, strrpos($url, '/') + 1); $foldername = 'somefolder'; echo $url . $foldername; ?> Link to comment https://forums.phpfreaks.com/topic/122506-solved-help-removing-last-part-of-a-url/#findComment-632539 Share on other sites More sharing options...
adam291086 Posted September 3, 2008 Author Share Posted September 3, 2008 thanks for that i found that i could get away with using explode and then echoing the end($piece) Link to comment https://forums.phpfreaks.com/topic/122506-solved-help-removing-last-part-of-a-url/#findComment-632541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.