Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getRecords() {
- $result = array();
- $isFirstLine = true;
- $headersArray = array();
- $columnsAmount = 0;
- if(($handle = fopen($this->filePath.$this->fileName, 'r')) !== FALSE) {
- while(!feof($handle)) {
- if(($output = fgetcsv($handle, (1024*2), $this->delim, $this->quoteType)) === FALSE) {
- continue;
- }
- if(!isset($output[1]) && '' === trim($output[0])) {
- continue;
- }
- if(empty($output)) {
- continue;
- }
- if(TRUE === $isFirstLine) {
- $isFirstLine = false;
- $headersArray = $output;
- $columnsAmount = count($output);
- continue;
- }
- if(count($output) !== $columnsAmount) {
- for($i = 0; $i <= $columnsAmount - count($output); $i++) {
- $output[] = array();
- }
- }
- $result[] = count($output);
- }
- }
- fclose($handle);
- return $result;
- }
Add Comment
Please, Sign In to add comment