fputcsv 和 fgetcsv
1 public function putcsv(){ 2 $list = M("ad")->limit(0,10)->select(); 3 $fp = fopen('./file.csv','w'); 4 foreach($list as $val){ 5 fputcsv($fp,$val); 6 } 7 fclose($fp); 8 9 }
public function getcsv(){ $file = "./file.csv"; $fp = fopen($file,'r'); while(($data = fgetcsv($fp)) !== false){ $arr[]=$data; } fclose($fp); }