时间:2021-07-01 10:21:17 帮助过:13人阅读
str_replace 用不了正则,用preg_replace 吧
正则能做到.
$str="http:\/\/www.sina.com\/music1\/23412455.mp3?time=2234523&type=mp3";
str_replace(substr($str,4,strpos($str,'?')),'abc',$str);
$urls = array("http:\/\/www.sina.com\/music1\/23412455.mp3?time=2234523&type=mp3","http:\/\/www.sina.com\/music2\/4325243.mp3?time=2234523&type=mp3","http:\/\/www.sina.com\/music3\/346553.mp3?time=2234523&type=mp3");foreach($urls as $url){ echo preg_replace('@http(.*?)\?@i','abc',$url).'
';}