```php $val){ $sOut = "\"{$mobile}\"," . "\"{$valurl_short}\"," . "\"{$valurl_real}\"," . "\"{$valuserName}\"," . "\"{$valuserId}\",\n"; $sOut = mb_convert_encoding($sOut, 'gbk'); echo $sOut; } } ?> ``` 下面的代码是我在项目中用到的,故copy ```php file = new SplFileObject($file); } public function run($project_id, $userid) { $this->readline = 500; //每次读取500行 $this->project_id = $project_id; $this->userid = $userid; $this->sendcloud = App::get('config')->get('sendcloud'); $this->createGroup(); $this->readCsv(); } public function readCsv() { $aCache = array(); while (!$this->file->eof()) { $linedata = $this->file->fgetcsv(); if(!empty($linedata)) { $aCache[] = $linedata; } if(count($aCache) == $this->readline) { if(!$this->checkAndSend($aCache)) { break; } $aCache = array(); } } if(!$this->checkAndSend($aCache)) { return; } $aCache = array(); } public function checkAndSend($aUser) { if(empty($aUser)) { return false; } foreach ($aUser as $key=>$value) { if (empty($value[0]) || empty($value[1]) || empty($value[2])) { continue; } //$value 下的数据 } return true; } } ```