note 29767 added to function.preg-replace

From: Date: Mon, 24 Feb 2003 19:21:17 +0000
Subject: note 29767 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-44443@lists.php.net to get a copy of this message
Is there a way you can call backreferenced variables later on in a script (like in perl)? For instance, if you have (*very* simple example): <code> $str = "blah@place.thing"; $str2 = preg_replace("/([A-z])@([A-z])\.([A-z])/", "$1 $2 $3", $str); </code> With this, $str2 is equal to "blah place thing". But is there a way I can reference $1 later on? I know that doesn't work because variables can't start with numbers. Right now I'm doing this: <code> //code from above list($user, $domain, $thing) = split(" ", $str2); </code> Is there an easier (read: better) way? -- http://www.php.net/manual/en/function.preg-replace.php http://master.php.net/manage/user-notes.php?action=edit+29767 http://master.php.net/manage/user-notes.php?action=delete+29767 http://master.php.net/manage/user-notes.php?action=reject+29767

« previous php.notes (#44443) next »