| PHP: Read data from a CSV file in PHP |
|
|
|
| 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); ?> |
Produk Safety
Kacamata Safety (72) Sepatu Safety (Safety Shoes) (216) Sarung Tangan (Hand Gloves) (14) Head & Face Protection (24) Hearing Protection (14) Safety Clothes & Vest (26) Masker & Hood (40) Full Body Harness & Safety Belt (16) Safety Sign (9) Miscellaneous (5) Metal Detector (6) Coveralll Nomex (3)Usefull Site
Contact Us
Another Menu
| Blog |
| Old Shop |
| Javascript |
| PHP |
| Linux |












