load->helper('security'); $csv_rows = []; //Skip Byte-Order Mark if(bom_exists($csv_file) === TRUE) { fseek($csv_file, 3); } $headers = fgetcsv($csv_file); while(($row = fgetcsv($csv_file)) !== FALSE) { //Skip empty lines if($row !== array(null)) { $csv_rows[] = array_combine($headers, $CI->security->xss_clean($row)); } } fclose($csv_file); } return $csv_rows; } function bom_exists(&$file_handle) { $result = FALSE; $candidate = fread($file_handle, 3); rewind($file_handle); $bom = pack('CCC', 0xef, 0xbb, 0xbf); if (0 === strncmp($candidate, $bom, 3)) { $result = TRUE; } return $result; } ?>