RE: [PHP] ereg_replace

From: Date: Thu, 15 Feb 2001 16:32:18 +0000
Subject: RE: [PHP] ereg_replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39930@lists.php.net to get a copy of this message
Ah right, strings not words, I feel like a dummy now... ;-) > -----Original Message----- > From: John Vanderbeck [mailto:agathorn@cfl.rr.com] > Sent: Thursday, February 15, 2001 10:57 AM > To: brian@gfx.cncdsl.com; Robin Vickery; php-general@lists.php.net > Subject: Re: [PHP] ereg_replace > > > > why does this > > > > <?php > > $string = "this is my string."; > > > > print $string . "<br>\n"; > > > > $string = preg_replace( > > array( '/is/', '/string/' ), > > array( 'is not', 'bit of text' ), > > $string > > ); > > > > print $string . "<br>\n"; > > ?> > > > > This happens because you are replacing "is" with "is not" so parse your > string by hand: > > "this is my string"..ok the first occurence of "is", is in the > word "this", > so do the replace..the replaced part in CAPS: > "thIS NOT" .. then the second "is": > thIS NOT IS NOT" etc..I think you can see why now.. > > - John Vanderbeck > - Admin, GameDesign > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#39930) next »