换行线已经删除了吗?

I'm using a CSV script from phpclasses.org. It retrieves column names and column values from a table/more tables and creates a CSV.

There's one thing I don't understand.

Here's the piece of code I'm looking at:

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

}

The 2 lines I'm wondering about are:

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

I thought rtrim removes new lines too ( )... so why is the second line $row[$key] = str_replace("\015\012",' ',$row[$key]); used?

rtrim removes newlines from the end (r = "right") of the string. The line you quoted removes them anywhere in the string.

Looking at the page you kindly linked in your question, I can read

from the end of a string

so, I can conclude that it doesn't remove any new lines from whatever else part of the string.