note 29767 rejected from function.preg-replace by ronabop
| From: | ronabop@php.net | Date: | Mon, 24 Feb 2003 21:22:58 +0000 |
| Subject: | note 29767 rejected from function.preg-replace by ronabop | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-44450@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?