這邊比較要注意的是編碼問題,
通常excel轉出來的編碼都是big5,
所以必需再利用程式去處理編碼!
$file = fopen("檔案","r"); $rows = 1; while($data = fgetcsv($file,1024,",")) //1024為csv字串長度 { foreach ($data as $key => $v) { $data[$key] = iconv("big5","UTF-8",$v);//轉換編碼 } $num = count($data); echo " 第 $rows 行有 $num 筆資料 "; $rows++; } fclose($file);