- Cisco ASA Hanging at ROMMON at Boot
- Microsoft SQL Server Verion Info
- OSX VPN Client DES Support
- Changing Windows RDP port
- Distinguished Name (DN) of Logged in User on Windows7
- ESXi Multiplathing Options
- DELL PowerConnect - What does "iscsi enable" do?
- VMware - LabManager - CannotAccessNetwork error deploying VM
- Nagios - Switch Interface Traffic
- How To - Linux Server Performance
PHP - Read Data from a CSV file
- Scripting:
I found myself needing to alter a PHP program I had that queried for data to one that read from a CSV file. After a little research, seems it is really straight forward. There is the fgetcsv function which makes it all a snap. Here is the example from PHP.net's website.
<?php
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
}
?>
WARNING - I'm not an expert coder/developer, just posting little bits I learn as I go.
- MWalker's blog
- Printer-friendly version
- Login to post comments
-
