[thechat] perl vs. php - string replacement

Joxn joxn at vernum.com
Wed May 30 14:17:43 CDT 2001


Hi,
I want to "x"-out every character but leave the first two as they are.
Just wondering if this can be done in PHP as easy as in Perl.

Perl:
substr($var,2,) =~ s/./x/g;

PHP:
$var = substr_replace($var, str_repeat("x", (strlen($var)-2)), 2);

I can live with the PHP version, but it doesn't really look nice, eh?

bye Joxn
-- 
   || //\\ \\// |\\||  ::  joxn at vernum.com  ::
 \\|| \\// //\\ ||\\|  ::      8053703      ::




More information about the thechat mailing list