Re: [PHP4BETA] replacing a substring

From: Date: Sat, 13 Nov 1999 02:25:25 +0000
Subject: Re: [PHP4BETA] replacing a substring
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-6163@lists.php.net to get a copy of this message
Lars Torben Wilson wrote: > > 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 I don't want to replace all occurences of the string, just one in a certain place, if str_replace had arguments to specify, pos, and max_replaces, then it would work... did that make sense? Tom > > Cheers, > > Torben

« previous php.version4 (#6163) next »