In article <000b01c10f4a$d569c5c0$0300a8c0@sparlak>,
 [EMAIL PROTECTED] (Philip Murray) wrote:

> 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?

See the docs on str_replace() or preg_replace, both of which can take 
arrays as arguments, or on strtr() which appears to be the most direct 
equivalent to your Perl expression.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to