Re: String Replacement

From: Date: Mon, 15 Jan 2001 03:42:06 +0000
Subject: Re: String Replacement
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-5017@lists.php.net to get a copy of this message
lol... Ok, so you want to replace ONLY the word "boy" with the word "girl"... you don't want to touch "boys". Perhaps str_replace("boy ", "girl ", $myStr) would do the trick? --Toby ----- Original Message ----- From: "Flint Doungchak" <Flint@netsolutionsllc.com> To: "'Toby Butzon'" <php-lists@imawebdesigner.com>; "Flint Doungchak" <Flint@netsolutionsllc.com>; <php-windows@lists.php.net> Sent: Sunday, January 14, 2001 10:35 PM Subject: RE: [PHP-WIN] String Replacement > OK, > > Let's try this to clarify... I hope. > > str_replace("boy","girl","$string"); > > In my case, PHP finds the 'boy' in boys and replaces it with 'girl' giving > me 'girls' which is not what I want. > > Boy, I hope that makes sense. > > -Flint > > -----Original Message----- > From: Toby Butzon [mailto:php-lists@imawebdesigner.com] > Sent: Sunday, January 14, 2001 7:29 PM > To: Flint Doungchak; php-windows@lists.php.net > Subject: Re: [PHP-WIN] String Replacement > > > Seems to me that you've got what you want... > > If I'm reading you right, you want to keep plural words plural and singular > words singular... so boys would become girls and boy would become girl. > Well... if you just replace boy with girl you get that result... > > So I'm not seeing the problem... enlighten me? ;) > > --Toby > > ----- Original Message ----- > From: "Flint Doungchak" <Flint@netsolutionsllc.com> > To: <php-windows@lists.php.net> > Sent: Sunday, January 14, 2001 10:24 PM > Subject: [PHP-WIN] String Replacement > > > > Hello all, > > > > Hope you all had a nice weekend. Simple question, I think. > > > > I would like to find all occurance of: > > > > boy or boys > > > > and replace it with: > > > > girl or girls > > > > respectively. > > > > My problem is that using the str_replace function like this: > > > > str_replace("boy","girl","$string"); > > > > turns boys into girls. > > > > I guess I want an exact match or some fuzzy intelligent thing. Did I > explain > > myself well. This isn't so easy to write down. > > > > Thanks in advance. Take care. > > > > -Flint > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > > For additional commands, e-mail: php-windows-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.windows (#5017) next »