我想从给定的URL中删除"&start = 2".这是我试过的:
$uri = "http://test.com/test/?q=Marketing&start=2";
$newuri = str_replace("&start=","",$url);
echo $newuri;
Run Code Online (Sandbox Code Playgroud)
你会想要使用preg_replace它:
$newuri = preg_replace('/&start=(\d+)/','',$uri);
Run Code Online (Sandbox Code Playgroud)