You should use preg_replace function.
Example:
$str="var=104&anothervar=10&page=14&name=stack";
$str = preg_replace('/&?page=\d+&?/', '', $str);
echo $str;
&page=\d+?
[&]?
means 0 or 1 occurence of&
character. (in case it was first parametr ampersand with no ampresand in the begining)\d+?
means at least 1 or more number after=
Output:
var=104&anothervar=104&name=stack
9
solved Regular expression to remove text + int [closed]