Jump to content


Photo

Stripping Line Breaks


  • Please log in to reply
3 replies to this topic

#1 verycleanteeth

verycleanteeth
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 28 July 2006 - 04:13 AM

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:

$mess = '
<table id="sometable">
    <tr>
    <td>
        <table id="thatguyfromwham">
             <tr>
             <td>
                      stuff to read
             </td>
             </tr>
        </table>
    </td>
    </tr>
</table>
';

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.

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 04:15 AM

try

$mess=stripslashes($mess);
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 28 July 2006 - 04:23 AM

The OP didn't ask how to strip back-slashes, he wants to remove all newline characters. Try:
<?php str_replace(array("\r\n","\n"),'',$mess) ?>

Ken

#4 verycleanteeth

verycleanteeth
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 28 July 2006 - 04:37 AM

That's exactly what I was looking for! Thanks Ken.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users