I have been looking around now for a while, and I have spent a good amount of time with trial and error, and still can’t get things right :/
What I am trying to do is take a string like a url:
www.something.com/something.html?user=1&page=1
and remove the "&page=1" out of the string. This string may have another &variable after "&page=*", so I would like it to only remove the "&page=*".
What I have been trying is:
$url = preg_replace("/&page=\.{*}&?/","",$url);
so in other words: "&page=" + anynumber + till end of number or next "&"
Any ideas?
Thanks!
This matches
&page=followed by 0 or more (that’s the*bit) characters that aren’t&or#.[...]stands for a set of characters;[^...]inverts the set.In other words, it will match everything after
&page=up to the next&or#(or end of string).