Re: [PHP4BETA] replacing a substring
| From: | Lars Torben Wilson | Date: | Sat, 13 Nov 1999 01:38:12 +0000 |
| Subject: | Re: [PHP4BETA] replacing a substring | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-6162@lists.php.net to get a copy of this message | ||
Tom Fishwick writes:
> Hi,
>
> Just recently I needed to replace a substring in a string, is there such
> a function in PHP? I couldn't find one so ended doing two substr
> operations then joining it again.
>
> I believe in Perl it would be substr($str, pos, len) = $name
>
> I'm not sure how often this is done, but would it be posible to add an
> optional argument to substr, that if present would replace the substr
> with that argument?
>
> Tom
http://www.php.net/manual/function.str-replace.php3
http://www.php.net/manual/function.ereg-replace.php3
http://www.php.net/manual/function.preg-replace.php3
Cheers,
Torben