The fgets() function is used to read a single line from a file. After a call to this function the file pointer has moved to the next line.
If you had separated your data with new lines then you could read in one segment of data at a time with the fgets function.
The example below reads a file line by line, until the end of file is reached:
$fh = fopen(“testfile.txt”, “r”) or exit(“Can’t open file!”);
//Output a line of the file until the end is reached
And The fgetc() function is used to read a single character from a file. After a call to this function the file pointer moves to the next character.
The fgetc() reads a file character by character, until the end of file is reached.