samoht Posted June 18, 2008 Share Posted June 18, 2008 Hello all, I have a simple question - that I used to know how to do bu for got I have a variable $mm_action_url that returns the base url that url strings get attached to. Anyway on my localhost things work fine but live (ex www.mysite.com) there is an extra slash (ie. www.mysite.com//myurlstring/...) What is the php for removing the last slash on my variable? Thanks Link to comment https://forums.phpfreaks.com/topic/110817-solved-simple-remove-last-charater-on-string/ Share on other sites More sharing options...
moderith Posted June 18, 2008 Share Posted June 18, 2008 Hi, Samoht Heres what I would do. $url = 'http://www.mysite.com//'; $newurl = substr($url, 0, -1); echo $newurl; //http://www.mysite.com/ Happy Coding Link to comment https://forums.phpfreaks.com/topic/110817-solved-simple-remove-last-charater-on-string/#findComment-568574 Share on other sites More sharing options...
samoht Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks! substr is what I was looking for. Not sure why I forgot Link to comment https://forums.phpfreaks.com/topic/110817-solved-simple-remove-last-charater-on-string/#findComment-568577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.