public static function putSomeData($file, $data) { if (empty($data)) { return true; } if (!file_exists($file)) { return self::putAllData($file, $data); } if ($content = parent::getFileContent($file)) { //得到表头数据 $rows = explode("\r\n", $content); $title = explode("|", $rows[0]); $rows = array(); $special = array("|", "\r\n"); //按照表头数据 来整合新数据 foreach ($data as $adata) { if (!$adata) { continue; } $row = array(); foreach ($title as $item) { $row[] = str_replace($special, " ", $adata[$item]); } $rows[] = join("|", $row); } $content = "\r\n" . join("\r\n", $rows); return parent::putFileContent($file, $content, FILE_APPEND); } else { return false; } }