verycleanteeth Posted July 28, 2006 Share Posted July 28, 2006 I know this should be easy to do, but I'm just not sure how. I've got a string storing some HTML like so:[code]$mess = '<table id="sometable"> <tr> <td> <table id="thatguyfromwham"> <tr> <td> stuff to read </td> </tr> </table> </td> </tr></table>';[/code]Is there a function I can call to strip all the line breaks out? My table is showing up right now with all sorts of extra whitespace because of all the extra lines, and I want to keep the HTML readable. Quote Link to comment https://forums.phpfreaks.com/topic/15853-stripping-line-breaks/ Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 try$mess=stripslashes($mess); Quote Link to comment https://forums.phpfreaks.com/topic/15853-stripping-line-breaks/#findComment-64967 Share on other sites More sharing options...
kenrbnsn Posted July 28, 2006 Share Posted July 28, 2006 The OP didn't ask how to strip back-slashes, he wants to remove all newline characters. Try:[code]<?php str_replace(array("\r\n","\n"),'',$mess) ?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/15853-stripping-line-breaks/#findComment-64968 Share on other sites More sharing options...
verycleanteeth Posted July 28, 2006 Author Share Posted July 28, 2006 That's exactly what I was looking for! Thanks Ken. Quote Link to comment https://forums.phpfreaks.com/topic/15853-stripping-line-breaks/#findComment-64972 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.