How can the file() function in PHP be used to read data from a file line by line for processing?
To read data from a file line by line in PHP, you can use the file() function, which reads the entire file into an array with each element representing a line of the file. You can then loop through this array to process each line individually.
$file = 'data.txt';
$lines = file($file);
foreach ($lines as $line) {
// Process each line here
echo $line;
}