How can PHP be used to read the last line of a CSV file and extract columns separately?
To read the last line of a CSV file and extract columns separately in PHP, you can use the `fgetcsv()` function to read the file line by line until reaching the last line. Then, you can explode the last line by the delimiter (usually a comma) to separate the columns.
<?php
$filename = 'data.csv';
$file = fopen($filename, 'r');
$lastLine = '';
while (!feof($file)) {
$lastLine = fgetcsv($file);
}
fclose($file);
$columns = explode(',', $lastLine[0]);
foreach ($columns as $column) {
echo $column . PHP_EOL;
}
?>