Remove text from middle of url
Not the best way to do this...preg_match or rtrim. Can't get either working...
$insert = http://ww开发者_运维技巧w.site.com/buy/vancouver/house
$insert = rtrim("$insert", "/buy");
No change.
Thanks for the help.
Something like this?
$insert = 'http://www.site.com/buy/vancouver/house';
$insert = str_replace('/buy','',$insert); // http://www.site.com/vancouver/house
If you want to remove only the first occurrence, you can use preg_replace:
$insert = 'http://www.site.com/buy/vancouver/house/buy/dwed';
$insert = preg_replace('#/buy#', '', $insert, 1);
精彩评论