I have typed the following code in PHP to read the text "yusuf123" from the external text file called "sample.txt" and to count and print the total number of digits. The code is surprisingly counting 4 digits instead of 3.
$file = fopen("sample.txt", "r");
$count = 0 ;
while(!feof($file))
{
$ch = fgetc($file);
if($ch >= '0' && $ch <= '9')
$count++;
}
echo $count ;
fclose($file);
?>
The output of the above code is 4 instead of 3. Kindly help me resolving this. Thanks in advance