Hi guys, thanks for your replies and apologies for any incoherence in my original posting.
My aim was to do this: To open a text file called 'log.txt', which contains a series of strings like 'a1 a2 a2 a1 a2' on new lines. I wanted to count these and pull out the total occurances of each.
Someone on IRC Dalnet #php came up with the following solution which does the job:
<?php
$filename = "../log.txt";
$fp = fopen($filename,"r");
$haystack = fread($fp,filesize($filename));
$needle1 = "a1";
$needle2 = "a2";
$num_occurs1 = count(explode($needle1,$haystack)) - 1;
$num_occurs2 = count(explode($needle2,$haystack)) - 1;
$total1 = $num_occurs1;
$total2 = $num_occurs2;
?>
I could not use substr_count because I do not have PHP4 and not likely to have it on my ISP until a few months time.
The above gives me exactly what I want, the totals I can use to plot my graph.
Many thanks