Re: Counting total number of string occurence within a text file
| From: | (Richard Lynch) | Date: | Wed, 08 Nov 2000 20:41:10 +0000 |
| Subject: | Re: Counting total number of string occurence within a text file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24382@lists.php.net to get a copy of this message | ||
In article <007501c0472a$b5eed2a0$39379fd4@jesus.cam.ac.uk>,
team@idomaincart.com ("iDomainCart") wrote:
> I'd like to open a text file using PHP, which I know how to do, and count
> the number of instances of a string, which I don't know how to do! There are
> in particular 6 types of string. I'd like to count the total of each and use
> each total to form the data for a graph .
>
> 1. Is my methodology correct? ie. opening up the file first and then reading
> from it? Or is there a more elegant way?
It depends on the nature of the strings...
Are they all "static" or more of a pattern?
Do they overlap?
You may find that using strtok() repeatedly will be fastest...
Or maybe you need to re-read the file 6 times and do a lot of ereg_match()
to get it right.
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)