reyes99 Posted June 19, 2007 Share Posted June 19, 2007 Hi, I am new to PHP and I am lookig for more information on the formating strings for example \n\r I was trying to find them on google to read more about them but not sure what to search for. Could somone please tell me where I can find some more information on this. or maybe yo ucan help me with my issue. I created thsi function and I want to clean up a comment field from ? and ,s but I want it to continue the line. it is creating a new line when I try to convert it to an Excel .csv file. Thanks Here is my code: <center><h1><img border="0" src="banner.gif" width="805" height="70"></h1> <h1>Survey Results</h1></center> <?php function cleancomm($comm) { $comm1 = str_replace('?', ' ', $comm); $comm2 = str_replace(',', ' ', $comm1); return $comm2; } require 'config.php'; require 'opendb.php'; $fp = fopen('file.csv','wa'); $q = 'select * from survey'; $query = mysql_query($q); while ($row = mysql_fetch_array($query)) { $nextline = $row[0] . ',' . $row[1] . ',' . $row[2] . $row[3] . ',' . $row[4] . ',' . $row[5] . ',' . $row[6] . ',' . $row[7] . ',' . $row[8] . ',' . $row[9] . ',' . $row[10] . ',' . $row[11] . ','. $row[12] .',' . cleancomm($row[13]) . ',' . cleancomm($row[14]) . "\r\n"; fwrite($fp,$nextline); } fclose($fp); ?> Quote Link to comment https://forums.phpfreaks.com/topic/56273-formatting-question/ Share on other sites More sharing options...
gterre Posted June 19, 2007 Share Posted June 19, 2007 I have the same problem, I tried replacing \n, \t, \r with '' But for some reason, when I export my files to excell, the comment fields that contained the \n \t \r, resulted in a new line. I would like to strip a field from all formatting chars. html entities does not work... Quote Link to comment https://forums.phpfreaks.com/topic/56273-formatting-question/#findComment-278044 Share on other sites More sharing options...
reyes99 Posted June 20, 2007 Author Share Posted June 20, 2007 I have the \r\n at the end of the line but in the comment field it is cutting it and adding multiple rows for each part where it cleans the field of "?" and ","'s. Not sure what the problem is??? cleancomm($row[14]) . "\r\n"; I think the problem is when I strip it of all the ? and ,'s it just cuts it. I would like to know how I can get the whold comment to stay together before the next line or row. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/56273-formatting-question/#findComment-278477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.