D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
admission
/
application
/
libraries
/
Filename :
CSVHandler.php
back
Copy
<?php /** * Library For All Util Tasks Related To Sessions * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class CSVHandler { public static function readCSV($filePointer) { $csv_data = []; if (($handler = fopen("{$filePointer}", "r")) !== FALSE) { while (($data = fgetcsv($handler, 1000, ",")) !== FALSE) { $csv_data[] = $data; } fclose($handler); } return $csv_data; } public static function writeCSV($csvFileNameAndPath, $csvContents, $isNew) { if($isNew){ $new_csv = fopen($csvFileNameAndPath, 'w'); }else{ $new_csv = fopen($csvFileNameAndPath, 'a'); } fputcsv($new_csv, $csvContents); fclose($new_csv); } }