开发者

How can I replace ?myuser=number with an empty string in PHP

How can I replace a string containing a lot of ?myuser=12122 ?myuser=5457 ... with empty string so that it doesn't show ?myuser=number inside the string?

I think I开发者_StackOverflow should use regex?


yes,

 preg_replace('~\?myuser=\d+~', '', $string);


The question mark is a special character in regular expressions, so you must quote it. Apart from that, it's quite straight forward:

$result = preg_replace('/\?myuser=[0-9]+/', '', $source);


$str = preg_replace("/\?myuser=(\d+)/iU","",$yourstring);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜