Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Isn';新行不是已经删除了吗?_Php_String - Fatal编程技术网

Php Isn';新行不是已经删除了吗?

Php Isn';新行不是已经删除了吗?,php,string,Php,String,我正在使用phpclasses.org上的CSV脚本。它从表/多个表中检索列名和列值,并创建CSV 有一件事我不明白 下面是我正在查看的一段代码: function createcsv($tablename){ $rs = $this->SelectAll($tablename); $rs1 = $this->SelectAll($tablename); if($rs){ $string =""; /// Get the f

我正在使用phpclasses.org上的CSV脚本。它从表/多个表中检索列名和列值,并创建CSV

有一件事我不明白

下面是我正在查看的一段代码:

function createcsv($tablename){

    $rs  = $this->SelectAll($tablename);
    $rs1 = $this->SelectAll($tablename);
    if($rs){
        $string ="";
        /// Get the field names
        $fields =  mysql_fetch_assoc($rs1);
        if(!is_array($fields))
          return;
        while(list($key,$val) =each($fields)) {
            $string .= $key.',';
         }
        $string = substr($string,0,-1)."\015\012"; //removes last and comma and adds a newline
        /// Get the data
        while($row = mysql_fetch_assoc($rs)) {
            while(list($key,$val) =each($row)){
              $row[$key] = strip_tags(html_entity_decode($row[$key])); //strips tangs from the html decoded value
              $row[$key] = str_replace(',',' ',rtrim($row[$key])); //replaces commas with empty spaces from the trimmed value
              $row[$key] = str_replace("\015\012",' ',$row[$key]); 
            }
            $string .= (implode($row,","))."\015\012";
         }
            echo $string;

        //$fp = fopen($this->path.$tablename.".csv",'w');
        //fwrite($fp,$string);
        //fclose($fp);
    }

}
我想知道的两行是:

$row[$key] = str_replace(',',' ',rtrim($row[$key])); //replaces commas with empty spaces from the trimmed value
$row[$key] = str_replace("\015\012",' ',$row[$key]); 

我还以为会删除新行(\n)。。。那么,为什么第二行
$row[$key]=str_replace(“\015\012”,”,“$row[$key])已使用?

rtrim
从字符串的末尾(r=“right”)删除换行符。您引用的行将删除字符串中的任何位置。

rtrim
从字符串的末尾(r=“right”)删除换行符。您引用的行将删除字符串中的任何位置。

看着您在问题中善意链接的页面,我可以阅读

从字符串的端开始


因此,我可以得出结论,它不会从字符串的任何其他部分删除任何新行

看着你在问题中善意链接的页面,我可以阅读

从字符串的端开始

因此,我可以得出结论,它不会从字符串的任何其他部分删除任何新行