netjunky

Untitled

Sep 22nd, 2010
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. public function getRecords() {
  2.     $result = array();
  3.     $isFirstLine = true;
  4.     $headersArray = array();
  5.     $columnsAmount = 0;
  6.        
  7.     if(($handle = fopen($this->filePath.$this->fileName, 'r')) !== FALSE) {
  8.         while(!feof($handle)) {
  9.             if(($output = fgetcsv($handle, (1024*2), $this->delim, $this->quoteType)) === FALSE) {
  10.                 continue;
  11.             }
  12.             if(!isset($output[1]) && '' === trim($output[0])) {
  13.                 continue;
  14.             }
  15.             if(empty($output)) {
  16.                 continue;
  17.             }
  18.             if(TRUE === $isFirstLine) {
  19.                 $isFirstLine = false;
  20.                 $headersArray = $output;
  21.                 $columnsAmount = count($output);
  22.                
  23.                 continue;
  24.             }
  25.             if(count($output) !== $columnsAmount) {
  26.                 for($i = 0; $i <= $columnsAmount - count($output); $i++) {
  27.                     $output[] = array();
  28.                 }
  29.             }
  30.             $result[] = count($output);
  31.         }
  32.     }
  33.     fclose($handle);
  34.        
  35.     return $result;
  36. }
Add Comment
Please, Sign In to add comment