title: php export csv i want to sum price column
body: <p>I have table that has item,desc,price.
  When i export as csv i want to sum the price column and put in the last row like sub total. csv generated fine.. i need to sum price column.</p>
  
  <pre><code>    header('Content-Type: text/csv; charset=utf-8');
      header('Content-Disposition: attachment; filename=' . $type . '-' . date('Y-m-d') . '.csv');
      $output = fopen('php://output', 'w');
  
  
       foreach ($price_list as $car) {
          $i++;
          $rows[$i][id] = $car-&gt;id;
          $text = $car-&gt;item;
          $rows[$i][des]=$car-&gt;des;
          $rows[$i][text] = preg_replace('/\s+/S', " ", $text);
          $rows[$i][price]=$car-&gt;price;
          $rows[$i][stocks]=$car-&gt;stocks;
  
          $rows[$i][edited_dt] = $car-&gt;edited_dt;
  
  
      }
  
  
  
  
      foreach ($rows as $row) {
          fputcsv($output, $row);
      }
  </code></pre>
  
  <p>//query
  select id,p_type,item,des,price,price_unit,stocks,stocks_unit,created_dt,created_by,edited_dt
                  from price_list where state=1<br>
                  order by id desc</p>