URL上的PHP str_replace

Agu*_*nto 0 php

我想从给定的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)

bri*_*vis 6

你会想要使用preg_replace它:

$newuri = preg_replace('/&start=(\d+)/','',$uri);
Run Code Online (Sandbox Code Playgroud)