Regular expressions
| From: | Philip Murray | Date: | Wed, 18 Jul 2001 05:31:02 +0000 |
| Subject: | Regular expressions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-58387@lists.php.net to get a copy of this message | ||
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
------------- - -- - -