Jump to content

Archived

This topic is now archived and is closed to further replies.

verycleanteeth

Stripping Line Breaks

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.