dongzhent208577 2016-06-09 03:03
浏览 50

多维数组+ CSV导出

I have an issue with an export script im trying to write...

  1. I create a multidimensional array

    while($row = $insert_row->fetch_assoc()) {

        foreach ($selectArray as $value) {
            $userData = $row[$value];
            $userDataArray[] = $userData;
        }
        $userArray[] = $userDataArray;
        unset($userDataArray);
    }
    
  2. Now I want to create the CSV File

    $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);
    

Im getting the error "fputcsv() expects parameter 2 to be array, string given"

Any solution?

  • 写回答

1条回答 默认 最新

  • doutongwei4380 2016-06-09 03:19
    关注

    Already fixed, I went one level to deep on fput...

    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM