开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜