mlavwilson Posted October 9, 2006 Share Posted October 9, 2006 I am using xoops, and thier news module insists on replacing slash-n with br. The problem is when I try to insert tables into an article I get a huge amount of br. I am weak on regex, can someone help me with a regex to remove all the slash-n that occure between the start and end table...slash-n...table? Link to comment https://forums.phpfreaks.com/topic/23420-removing-slash-n-between-table-tags-solved/ Share on other sites More sharing options...
effigy Posted October 9, 2006 Share Posted October 9, 2006 [code]<pre><?php $data = <<<DATA <html> <body> before <table> <tr> <td>abc</td> </tr> <tr> <td>123 </td> </tr> </table> after </body> </html>DATA; function clean_table ($matches) { ### Remove new lines. $table_content = preg_replace("/\r\n/", '', $matches[1]); ### Clean up space between end/start tags. return $table_content = preg_replace('/(?<=>)\s+(?=<)/', '', $table_content); } echo $data = preg_replace_callback('%(?<=<table)(.+?)(?=/table>)%sm', 'clean_table', $data);?></pre>[/code] Link to comment https://forums.phpfreaks.com/topic/23420-removing-slash-n-between-table-tags-solved/#findComment-106253 Share on other sites More sharing options...
mlavwilson Posted October 9, 2006 Author Share Posted October 9, 2006 Many thanks! Link to comment https://forums.phpfreaks.com/topic/23420-removing-slash-n-between-table-tags-solved/#findComment-106319 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.