title: PhP export .csv change delimiter from comma to others
body: <p>I have this PhP code where in the user clicks a button and it automatically downloads a .csv file and inside it are different kinds of information. So this .csv file is comma delimited so it means whenever there is a comma the pointer goes to the next cell. But i'd like to change the delimiter to anything other than comma because some of my data has comma for example Location column has data such as 501A, 501B and it needs to be on a single cell. But instead it goes to another cell so id doesnt fit when I print it in portrait. So i just wanna ask how can I change the delimiter and maintain the data with commas? thanks!</p>
  
  <pre><code>&lt;?php
  define("DB_HOST", "localhost");
  define("DB_USER", "root");
  define("DB_PASS", "");
  define("DB_NAME", "envoy");
  function db_connect() {
  
    $db = mysqli_connect(DB_HOST, DB_USER, DB_PASS) or die("ERROR!");
    mysqli_select_db($db, DB_NAME);
  
    return $db;
  }
  
  $db = db_connect();
  date_default_timezone_set("EST5EDT");
  $date = date('m-d-Y,h.i.sa');
  $date2 = date('m/d/Y');
  $filename = $date.'.csv';
  //$fp = fopen($filename,"w");
  
  $sql2 = "SELECT sku as Sku,name as 'Brochure Name',location as Location FROM brochureinfo where modified LIKE '$date2' ORDER BY name  ";
  $rs2 = mysqli_query($db, $sql2);
  $total_records = mysqli_num_rows($rs2);
  mysqli_close($db);
  
  if($total_records&gt;0){
  $row = mysqli_fetch_assoc($rs2);
  
  $seperator = "";
  $comma = "";
  
  foreach ($row as $name =&gt; $value){
      $seperator.= $comma. ''.str_replace('','""',$name);
      $comma=",";
  
  }
  $seperator .= "\n";
  
  //echo $seperator;
  
  
  
  
  mysqli_data_seek($rs2,0);
  
  while ($row = mysqli_fetch_assoc($rs2)){
  
  
  //$seperator = "";
  $comma = "";
  
  foreach ($row as $name =&gt; $value){
  
              $value = str_replace( array( "\r" , "\n", "\r\n", "\n\r" ) ,'' , $value);
              $value = str_replace('&lt;/b&gt;&lt;br&gt;','',$value);
              $value = str_replace('&lt;b&gt;','',$value);
              $value = str_replace('&lt;br&gt;','',$value);
              $value = str_replace('&lt;br /&gt;','',$value);
  
      $seperator.= $comma. ''.str_replace('','""',$value);
      $comma=",";
  
      }
  $seperator .= "\n";
  }
  
  header('Content-Type: text/csv');
  header("Content-Disposition: attachment; filename=$date.csv");
  header('Pragma: no-cache');
  
  echo $seperator;
  }
  else{
      header('Content-Type: text/csv');
  header("Content-Disposition: attachment; filename=$date.csv");
  header('Pragma: no-cache');
  echo "No record modified today";}
  </code></pre>