note 79742 deleted from function.preg-replace by felipe

From: Date: Sat, 15 Dec 2007 15:35:46 +0000
Subject: note 79742 deleted from function.preg-replace by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133578@lists.php.net to get a copy of this message
Note Submitter: mit[at]hsdn.org Reason: 1 ---- Simple replace session id’s (sid) from URL <?php function replace_sid($url) { $ret = preg_replace('/([0-9A-Za-z]+)\=([0-9a-z]{32})/','',$url); if($ret != $url) { $ret = preg_replace('/\?\&/','?',$ret); $ret = preg_replace('/((\&|\?){1})$/','',$ret); } return $ret; } ?> Example $url = "http://s.com/l.php?SESSID=b53b3a3d6ab90ce0268229151c9bde11&q=5"; echo replace_sid($url); Return http://s.com/ll.php?q=5

« previous php.notes (#133578) next »