freakus_maximus Posted March 20, 2006 Share Posted March 20, 2006 Before anyone says I shouldn't allow tags in the initial form, I know. In this situation the application is internal (not on the 'net) and the user base limited. I am using a java app ("TinyMCE") to allow users to enter text and apply some limited formatting. The app stores the tags in the db along with the text. Such as:<strong>Here is some text</strong>I need to maintain this so I can present it back to the user in the same format. So, please no bashing about that. The problem I am having is actually with the following code. This grabs the data from the db and dumps it out to an Excel spreadsheet. This works, no problem there. But, I need to str_tags the "description" column in this example to remove the tags. Can't seem to figure out how to do that with the array. Any help? (I mentioned the str_replace as well in my Topic Title and hoping the solution to the first problem gives me direction on the this as well.)[code]$headers = ("FancyNameColumn1"."\t"."FancyNameColumn2"."\t"."FancyNameColumn3."\t");$result = mysql_query('select defectnum, description, username from release_notes_tbl');$count = mysql_num_fields($result);$data = array();while($row = mysql_fetch_row($result)) {array_push($data, $row);}$xls_rows = '';foreach( $data as $row )$xls_rows .= xls_format_row( $row );xls_send( $headers, $xls_rows );[/code]Thanks for any help! Link to comment https://forums.phpfreaks.com/topic/5368-how-to-str_tags-and-str_replace-in-an-array/ Share on other sites More sharing options...
micah1701 Posted March 20, 2006 Share Posted March 20, 2006 what if you strip it before you add it to the array:while($row = strip_tags(mysql_fetch_row($result))) {would that do it? (i didn't test it, just suggesting)if that doesn't workget your row count first, strip the tags, then use a for loop to build the array. something like:$rows = mysql_num_rows($results);$row = mysql_fetch_row($results);for($i=0; $i<$rows; $i++){$value = strip_tags($row[column]);array_push($value, $i)} Link to comment https://forums.phpfreaks.com/topic/5368-how-to-str_tags-and-str_replace-in-an-array/#findComment-19134 Share on other sites More sharing options...
freakus_maximus Posted March 20, 2006 Author Share Posted March 20, 2006 Hehe...oops!It was easier than I thought.I just added the two right before the xls_send since the data was being sent as one string.Thanks for the quick reply![code]foreach( $data as $row )$xls_rows .= xls_format_row( $row );$xls_rows = str_replace(array("</p><p>", "</li><li>"), ", ", $xls_rows);$xls_rows = strip_tags($xls_rows);xls_send( $headers, $xls_rows );[/code] Link to comment https://forums.phpfreaks.com/topic/5368-how-to-str_tags-and-str_replace-in-an-array/#findComment-19139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.