Advertisement
katiek

Reading CSV files into PHP

Feb 25th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. // usage: csv("intermed_meta.csv") gets you the 2d array for that csv file, blanks and all
  2.  
  3. function csv($fname){
  4.     $out = array();
  5.     if (($handle = fopen($fname, "r")) !== FALSE) {
  6.         while (($data = fgetcsv($handle)) !== FALSE) {
  7.             $out[] = $data;
  8.         }
  9.         fclose($handle);
  10.     }
  11.     return $out;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement