I have a very simple "PHP allowed" EE template that queries the EE db and generates CSV reports from it. I need to add to one of these reports the contents of one particular channel field, which happens to be a CKEditor field. The double quotes and line breaks within the contents of this field in some rows are wreaking havoc with my CSV output, and other HTML doesn't actually break the CSV but is useless at best in the context of readable CSV output.
So what's the most straightforward way to strip out line breaks and doublequotes, and maybe also all HTML, without having to install any new add-ons, which to my eternal chagrin I cannot do on this site?
My full template code is below... you obviously won't be able to run it because my channel field definitions are unique, but it shows you the simplicity of what I am doing, so I'm hoping for a likewise simple solution to my HTML stripping issue.
<?php
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=report.csv');
?>"Title","URL title","First name","Last name","Notes"
<?
{exp:query sql="SELECT title, url_title, field_id_128 AS 'FirstName', field_id_129 AS 'LastName', field_id_132 AS 'Notes' FROM (exp2_channel_data cd JOIN exp2_channel_titles ct ON ct.entry_id = cd.entry_id) WHERE cd.site_id = 3 and cd.channel_id = 19 GROUP BY cd.entry_id ORDER BY field_id_129"}
?>"{title}","{url_title}","{FirstName}","{LastName}","{Notes}"<?
print "\n";
{/exp:query}
?>