RedBlueGreen SmallMediumLarge WideNarrowFluid
Your Cart 0 items,total ($0) View Cart
PHP: Read data from a CSV file in PHP PDF Print E-mail
User Rating: / 0
PoorBest 
Monday, 27 September 2010 19:08
<?php
// open the text file
$fd = fopen ("pilots.csv", "r");
// initialize a loop to go through each line of the file
while (!feof ($fd)) {
$buffer = fgetcsv($fd, 4096); // declare an array to hold all of the contents of each
//row, indexed
echo "n";
// this for loop to traverse thru the data cols
// when this is re-created with MySQL use the mysql_num_fileds() function to get
// this number
for ($i = 0; $i < 5; ++$i){
if ($buffer[$i] == ""){
$buffer[$i] = " ";
}
// print 's with each index
echo "$buffer[$i]n";
}
echo "n";
}
fclose ($fd);
?>