Fairly new to PHP and trying to figure out something that I can't get my head around too.

I have a URL below where I want to remove &page\_number=x. The page\_number variable and the number has to be removed with the function, which will always be at the end of the string.

> 
> <http://url.com/search/?location=london&page_number=1>
> 
> 
> 

I have tried a few versions of preg\_replace but I am not having any luck.

Thanks