-
-
//Set UTF-8 encoding - setlocale(LC_ALL, 'en_US.UTF-8');
- //csv path
- $csv_file = "csv/excel. csv";
- //Open the file in read-only mode
- $handle = fopen($csv_file, "r");
- //Define the result array
- $listarr = array();
- //Open a line in csv and use " ,"Split into arrays
- while($data = fgetcsv($handle, 1000, ",")){
- $num = count($data);
- for($i=0; $i<$num; $i++ ){
- $data[$i] = mb_convert_encoding($data[$i],"UTF-8","UTF-8");
- }// bbs.it-home.org
- $listarr[] = $ data;
- }
return $listarr;
-
Copy code
>>> More about generating (exporting) csv with php. |