Using a list of (string) variables as preg_match result set?
| From: | Antti Boman | Date: | Fri, 05 Jan 2001 07:41:15 +0000 |
| Subject: | Using a list of (string) variables as preg_match result set? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32845@lists.php.net to get a copy of this message | ||
Couldn't find the solution for my problem, not in FAQ, php.net search, Deja
or Google.
Instead of using an array as preg_match result set, I'd like to use a list
of basic string variables. For example:
$str="I think this is a stupid example, but it shoud show what I want to
know";
preg_match( "/(this) is a (stupid) example/", $str,
list($whole,$first,$second) );
...but it doesn't work.
In case you want to know why, it's only because I've used this kind of
construct in Perl, and now as I'm possibly switching to PHP, I'd like to
make a script that did most of the converting job. In Perl that'd be:
($first,$last)=$str=~/(this) is a (stupid) example/;
If you know the answer (even if it's a no-can-do), let me know.
Thanks!
-Antti Boman