我在尝试编写导出脚本时出现问题...
我创建了一个多维数组
while($ row = $ insert_row-> fetch_assoc()){
foreach ($selectArray as $value) {
$userData = $row[$value];
$userDataArray[] = $userData;
}
$userArray[] = $userDataArray;
unset($userDataArray);
}
现在我要创建CSV文件
$ sendfilename =“export”。名为 “.csv”; $ filename =“file”。名为 “.csv”; $ delimiter =';'; $ enclosure ='“'; $ encloseAll = true; $ nullToMysqlNull = false; $ delimiter_esc = preg_quote($ delimiter,'/'); $ enclosure_esc = preg_quote($ enclosure,'/');
$fp = fopen($filename, 'wb');
if ($fp)
{
foreach ($userArray as $users) {
foreach ($users as $fields) {
fputcsv($fp, $fields,";",'"');
}
}
}
fclose($fp);
readfile($filename);
我得到错误“fputcsv()期望参数2是数组,字符串给出”
任何解决方案?
答案 0 :(得分:0)
已经修好了,我在一个级别上深入了解...