script for counting a repetition of a specific word in a file

I am trying to make a script that counts the number of times a specific word appears on a page.
for that I have developed the following coding.
I am using it to count words on a wordpress site.
There are 11 of those words but it only shows 9.
Tried it some other pages the same error persists.
I am using preg_match to compare strings
[php]<?php
$file=fopen(“http://www.routemybrain.com/about/","r”) or exit(“Unable”);
$i=0;
while(!feof($file))
{
$fk=fgets($file);

if(preg_match('/Akash/',$fk))
	{echo $fk . "<br>";
	$i++;
	}
}

echo $i;
?>[/php]
please help

The code below will do this work correctly:
[php]<?php
$s=file_get_contents(‘http://www.routemybrain.com/about/’);

if(preg_match_all("/Akash/i",$s,$matches)){
echo ‘

’;
print_r($matches);
echo ‘
’;
}
?>[/php]

Or, better yet, change the first line to this:
[php]$s=strip_tags(file_get_contents(‘http://www.routemybrain.com/about/’));[/php]

this will eliminate all commented out text entries, and html/css element names & id’s.

Sponsor our Newsletter | Privacy Policy | Terms of Service