Re: count string within a string
| From: | Richard Lynch | Date: | Mon, 20 Nov 2006 23:01:43 +0000 |
| Subject: | Re: count string within a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244909@lists.php.net to get a copy of this message | ||
On Fri, November 17, 2006 11:29 am, Børge Holen wrote:
> I've figured out I need the substr_count function.
> However, counting strings like this: [1] [2] [3] ... [215] ...
> inside a large string element. damn.
> The string got quite a few different numbers and keys but the main key
> is
> alway within [] and is numeric.
> I imagine I could use a $counter++.
> I just dont see how I should aproach this.
>
> Anyone got an Idea?
A total hack might be to just substr_count the '[' occurences, if the
strings are guaranteed to be well-formed...
But the preg_match_all() is probably the Right Answer.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?