[thechat] perl vs. php - string replacement

Erika Meyer emeyer at lclark.edu
Wed May 30 14:31:43 CDT 2001


You DID mean to send this to the list didn't you?

I think you owe a dumb joke, a meaningless piece of trivia, some 
unfounded gossip, or random opinion.

Erika

>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