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);
加载中,请稍侯......
精彩评论