Forum : How to read a File Character by Character?
Brief description  about Online courses   join in Online courses
View prabeen  patra 's Profile

How to read a File Character by Character?

How to read a File Character by Character?????
Asked by prabeen patra | Mar 17, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Prabeen,
The fgetc() function is used to read a single character from a file.
Note: After a call to this function the file pointer moves to the next character.
Example
The example below reads a file character by character, until the end of file is reached:
<?php
$file=fopen("welcome.txt","r") or exit("Unable to open file!");
while (!feof($file))
{
echo fgetc($file);
}
fclose($file);
?>
Mar 17, 2010