Number of occurrences of characters in a text file using PHP

$count = 0;
$myFile = "file.txt";
$fh = fopen($myFile, 'r');

while(!feof($fh))
{
    $Char1 = fgetc($fh);
    if($fh == "a")
    {
        echo $fh;
        $count++;
    }
}
fclose($fh);

echo "Total 'a' inside File: " . $count;

Content of : file.txt

asdasdadaffl;sdgkjsdhfjkghsdfghsdkfvndm,vncmvskjdhfdafhaldfadcnasc adkfjhasdjkalfhadlhhfdskdfhdjkfasf aksdjfhajksdfhjkasdfhakdfasdkcsncandkn

asdkjfhaskdfcnslkjdshfa asdfjkadhfkashdfdknscnaskdjf

What i'm trying to do here is to count how many occurrences of character 'a' are found in this file. Please help.


why not just use something like

$count = 0;
$myFile = "file.txt";
$fh = fopen($myFile, 'r');
while(!feof($fh)){
    $fr = fread($fh, 8192);
    $count += substr_count($fr, 'a');
}
fclose($fh);
echo 'there are ', $count, " a's";