ArizonaJohn Posted June 23, 2009 Share Posted June 23, 2009 Hello, The code below removes "www.", etc. from the beginning of websites that are entered into a database. It works great. Is there a way I could use similar code to remove a forward-slash from the tail-end of a website that is entered into the same database? Thanks in advance, John $remove_array = array('http://www.', 'http://', 'https://', 'https://www.', 'www.'); $site = str_replace($remove_array, "", $_POST['site']); Link to comment https://forums.phpfreaks.com/topic/163317-solved-removing-a-forward-slash-from-the-tail-end-of-an-url/ Share on other sites More sharing options...
RussellReal Posted June 23, 2009 Share Posted June 23, 2009 $remove_array = array('http://www.', 'http://', 'https://', 'https://www.', 'www.'); $site = str_replace($remove_array, "", $_POST['site']); $site = preg_replace('/\/$/','',$site); Link to comment https://forums.phpfreaks.com/topic/163317-solved-removing-a-forward-slash-from-the-tail-end-of-an-url/#findComment-861679 Share on other sites More sharing options...
ArizonaJohn Posted June 23, 2009 Author Share Posted June 23, 2009 Thanks, it works. Link to comment https://forums.phpfreaks.com/topic/163317-solved-removing-a-forward-slash-from-the-tail-end-of-an-url/#findComment-861702 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.