How can PHP be used to read and display data from a CSV file?
To read and display data from a CSV file using PHP, you can use the `fgetcsv()` function to read each row of the CSV file and then display the data as needed. You can open the CSV file using `fopen()`, loop through each row using `fgetcsv()`, and then display the data in a table or any other format.
$csvFile = 'data.csv';
$handle = fopen($csvFile, 'r');
echo "<table>";
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
echo "<tr>";
foreach ($data as $value) {
echo "<td>" . $value . "</td>";
}
echo "</tr>";
}
echo "</table>";
fclose($handle);