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]
- [PHP] Regular expressions Matt Williams
- [PHP] Regular expressions Philip Murray
- RE: [PHP] Regular expressions Jack Dempsey
- [PHP] PHP based statistics/Gr... Chris Aitken
- Re: [PHP] PHP based stati... Rasmus Lerdorf
- Re: [PHP] PHP based ... eschmid+sic
- Re: [PHP] PHP ba... Joe Conway
- [PHP] Re: PHP based... Philip Hallstrom
- [PHP] Re: Regular expressions CC Zona
- [PHP] Re: Regular expressions Richard Lynch
- [PHP] Regular expressions Marc Davenport
- Re: [PHP] Regular expressions ReDucTor
- [PHP] regular expressions Gerard Samuel
- Re: [PHP] regular expressions Michael Sims
- Re: [PHP] regular expressions Michael Sims
- [PHP] regular expressions German Castro Donoso
- Re: [PHP] regular expressions Edward van Bilderbeek - Bean IT
- [PHP] Re: regular expressions Murray Chamberlain
- [PHP] Regular Expressions Devin Atencio