• <tfoot id='ZzBWA'></tfoot>

      <bdo id='ZzBWA'></bdo><ul id='ZzBWA'></ul>
      <i id='ZzBWA'><tr id='ZzBWA'><dt id='ZzBWA'><q id='ZzBWA'><span id='ZzBWA'><b id='ZzBWA'><form id='ZzBWA'><ins id='ZzBWA'></ins><ul id='ZzBWA'></ul><sub id='ZzBWA'></sub></form><legend id='ZzBWA'></legend><bdo id='ZzBWA'><pre id='ZzBWA'><center id='ZzBWA'></center></pre></bdo></b><th id='ZzBWA'></th></span></q></dt></tr></i><div id='ZzBWA'><tfoot id='ZzBWA'></tfoot><dl id='ZzBWA'><fieldset id='ZzBWA'></fieldset></dl></div>

      1. <legend id='ZzBWA'><style id='ZzBWA'><dir id='ZzBWA'><q id='ZzBWA'></q></dir></style></legend>

        <small id='ZzBWA'></small><noframes id='ZzBWA'>

        如何使用 php 以 .dat 或 .txt 格式导出文件

        How to export file in .dat or .txt format using php(如何使用 php 以 .dat 或 .txt 格式导出文件)
        • <bdo id='Em6Uu'></bdo><ul id='Em6Uu'></ul>
          1. <legend id='Em6Uu'><style id='Em6Uu'><dir id='Em6Uu'><q id='Em6Uu'></q></dir></style></legend>

                <tfoot id='Em6Uu'></tfoot>

                  <i id='Em6Uu'><tr id='Em6Uu'><dt id='Em6Uu'><q id='Em6Uu'><span id='Em6Uu'><b id='Em6Uu'><form id='Em6Uu'><ins id='Em6Uu'></ins><ul id='Em6Uu'></ul><sub id='Em6Uu'></sub></form><legend id='Em6Uu'></legend><bdo id='Em6Uu'><pre id='Em6Uu'><center id='Em6Uu'></center></pre></bdo></b><th id='Em6Uu'></th></span></q></dt></tr></i><div id='Em6Uu'><tfoot id='Em6Uu'></tfoot><dl id='Em6Uu'><fieldset id='Em6Uu'></fieldset></dl></div>
                    <tbody id='Em6Uu'></tbody>

                  <small id='Em6Uu'></small><noframes id='Em6Uu'>

                  本文介绍了如何使用 php 以 .dat 或 .txt 格式导出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有函数 export_csv() 将文件导出为 .csv 格式.我想更改 .dat 或 .txt 格式而不是 .csv

                  I have function export_csv()to export file as .csv format. I want to change .dat or .txt format instead of .csv

                  当前代码:

                  public function export_csv() {
                    
                    if( ! $this->path) { throw new exception('unable to create xls: missing path'); }
                         /** output conetnts to csv **/
                         ob_start();
                         $df = fopen($this->path.'.csv', 'w');
                         foreach ($this->data as $row) {
                         fputcsv($df, $row);
                         }
                        fclose($df);
                        return $this->path;
                  }
                  

                  我试过下面的代码.但是 .dat 文件是空白的.文件大小 0

                  I have tried below code. but .dat file was blank. The file size 0

                  public function export_dat() {
                      
                      if( ! $this->path) { throw new exception('unable to create xls: missing path'); }
                      /** output contents to dat **/
                          ob_start();
                          $df = fopen($this->path.'.dat', 'w');
                          foreach ($this->data as $row) {
                              fwrite($df, $row);
                          }
                           fclose($df);
                           
                           return $this->path;
                  }
                  

                  预先感谢您的帮助.

                  推荐答案

                  fwrite 接受一个字符串,而不是一个数组.尝试这样的事情:

                  fwrite takes a string, not an array. Try something like this:

                  fwrite($df, implode(', ', $row));
                  

                  这篇关于如何使用 php 以 .dat 或 .txt 格式导出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <legend id='3vIfY'><style id='3vIfY'><dir id='3vIfY'><q id='3vIfY'></q></dir></style></legend>

                1. <i id='3vIfY'><tr id='3vIfY'><dt id='3vIfY'><q id='3vIfY'><span id='3vIfY'><b id='3vIfY'><form id='3vIfY'><ins id='3vIfY'></ins><ul id='3vIfY'></ul><sub id='3vIfY'></sub></form><legend id='3vIfY'></legend><bdo id='3vIfY'><pre id='3vIfY'><center id='3vIfY'></center></pre></bdo></b><th id='3vIfY'></th></span></q></dt></tr></i><div id='3vIfY'><tfoot id='3vIfY'></tfoot><dl id='3vIfY'><fieldset id='3vIfY'></fieldset></dl></div>

                2. <small id='3vIfY'></small><noframes id='3vIfY'>

                  <tfoot id='3vIfY'></tfoot>
                      <tbody id='3vIfY'></tbody>
                    • <bdo id='3vIfY'></bdo><ul id='3vIfY'></ul>