Preg_Replace Question

Hello, I am trying to use preg_replace to clean up a string, I have read a few tutorial articles on how to use preg_replace with regex expressions, however even after all of the reading and my many tests, I am unable to get it right.

How, using preg_replace, would I clean out
type=th_is

I have a string of text,
ex: notes.php?function=view&sort=nt_tld&today=yes&msg=hello

and I would like to remove sort, and its value, and the &…
desired result would be

notes.php?function=view&today=yes&msg=hello

Can anybody help me with this??

I have been banging my head against a wall trying to understand how to do this…

sort=[^&]*&?

Cool,

$new_url = 'notes.php?function=view&type=none&sort=nt_tla';
$clean = '/sort=[^&]*&?/';
$new_url = preg_replace($clean,'', $new_url);

Worked just like I wanted.

Thanks for your help

Sponsor our Newsletter | Privacy Policy | Terms of Service