Forum Moderators: coopster
i have a log file that has one word entries in each line of the text file. i want to be able to determine how many times the word alpha appears to be in the log file and if the number of times it appears is an odd number then echo odd and if if it's even number then echo Even.
any ideas how I can do this?
thanks
$logfile = file_get_contents ( "test.txt" );
$count = substr_count($logfile, "alpha");
if ($count % 2) {
echo "Odd";
} else {
echo "Even";
}
the problem i am having is that if the word alphabet or alphanumeric exists then it also counts that as the word alpha.
can anyone tell me how i can limit it to find exactly the word alpha?