title: Save html code directly to CSV file without interpreting(Without Formatting)
body: <p>I am trying to save html code directly into a csv file. But when I save html get formated and save into csv without displaying html code:</p>
  
  <p>HTML Code I am trying to save into CSV is:</p>
  
  <pre><code>&lt;h3 style="text-align:justify"&gt;GREAT VISUAL&lt;/h3&gt; 
  &lt;div style="line-height: 20.7999992370605px; text-align: justify;"&gt;SOME TEXT SOME TEXT SOME TEXT SOME TEXT SOME TEXT SOME TEXT &lt;/div&gt;
  </code></pre>
  
  <p>It should save the html as it is not like:</p>
  
  <p>"GREAT VISUAL
  SOME TEXT SOME TEXT SOME TEXT SOME TEXT SOME TEXT SOME TEXT "</p>
  
  <p>PHP code I'm using for this is: </p>
  
  <pre><code>$array = array();
  $sub = array();
  $sub['Description_1'] = str_replace(array("\r", "\n", "\t"), "", $html1);
  $sub['Description_2'] = str_replace(array("\r", "\n", "\t"), "", $html2);
  
  function cleanData(&amp;$str) {
      $str = preg_replace("/\t/", "\\t", $str);
      $str = preg_replace("/\r?\n/", "\\n", $str);
      if (strstr($str, '"'))
        $str = '"' . str_replace('"', '""', $str) . '"';
  }
  
  $name = date("F-j-Y-g-i-s-a") . '-OutPut';
  $filename = $name . ".xls";
  
  header('Content-Encoding: UTF-8');
  header("Content-Disposition: attachment; filename=\"$filename\"");
  header("Content-Type: application/vnd.ms-excel;charset=UTF-8");
  $flag = false;
  foreach (array_filter($array) as $row) {
     if (!$flag) {
       // display field/column names as first row
       echo implode("\t", array_keys($row)) . "\n";
       $flag = true;
     }
     array_walk($row, 'cleanData');
     echo implode("\t", array_values($row)) . "\n";
  }
  exit;
  </code></pre>
  
  <p>Please can anybody help me? I tried many solutions on internet but can not find any working example.</p>