Re: [PHP4BETA] New function chrcount

From: Date: Mon, 24 Apr 2000 21:17:31 +0000
Subject: Re: [PHP4BETA] New function chrcount
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-14015@lists.php.net to get a copy of this message
On Tue, 25 Apr 2000, Andi Gutmans wrote: > At 03:58 PM 4/24/00 -0500, Andrei Zmievski wrote: > >On Mon, 24 Apr 2000, Peter Kovacs wrote: > > > You'll have to forgive me, I'm not entirely familiar with all the inner > > > workings of PHP, so I'm not exactly sure what the function does. I think > > > the complication arises because we are looking for all occurences, not > > > just a single occurence. > > > > > > For example take the following call str_count("aaaaaa", "aa") > > > > > > If we're just doing something like strpos then that's easy. However, in > > > this case is the answer 3 or is it 5? Its that kind of complication that > > > I was trying to avoid. > > > >You can really simplify it if you assume that after you match a string > >you simply start matching at the end of the previous match. So, in this > >case it would find 3 occurrences. I don't think the alternative is very > >useful. > > I agree with this kind of behavior. You don't want to get 5 matches on this > one. Okay, I'll implement that. I'll use my original code as a optimized case (is it even optimized?) when the needle's length is one. Otherwise I'll make calls to php_memnstr. Give me a few minutes and I'll submit another patch. Peter -------------------------------------------------- Peter D. Kovacs KnowPost.com LLC Lead Engineer peter@knowpost.com --------------------------------------------------

« previous php.version4 (#14015) next »