What is the potential issue with using the file() function in PHP to read a text file into an array?

The potential issue with using the file() function in PHP to read a text file into an array is that it reads the entire contents of the file into memory at once, which can be inefficient and lead to performance issues when dealing with large files. To solve this issue, you can use the fopen() function to open the file and read its contents line by line using fgets().

$lines = [];
$handle = fopen("file.txt", "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        $lines[] = $line;
    }
    fclose($handle);
}