RE: [PHP] Regular expressions
| From: | Jack Dempsey | Date: | Wed, 18 Jul 2001 05:37:22 +0000 |
| Subject: | RE: [PHP] Regular expressions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58388@lists.php.net to get a copy of this message | ||
Checkout www.php.net/strtr
-----Original Message-----
From: Philip Murray [mailto:me@philth.net.nz]
Sent: Wednesday, July 18, 2001 1:31 AM
To: PHP General List
Subject: [PHP] Regular expressions
In Perl you can do this:
$foo =~ tr/012/mpf/;
Which is the same as:
$foo = str_replace("0", "m", $foo);
$foo = str_replace("1", "p", $foo);
$foo = str_replace("2", "f", $foo);
in PHP.
Is there a more elegant way of doing this in PHP? I tried preg_replace
but
it didn't seem to like my regexp.
Any ideas?
-------------------------------- - -- - - -
Philip Murray
me@philth.net.nz
------------- - -- - -
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net