SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing whitespace from between HTML tags

    Does anyone know how to turn this:
    Code:
             <table>
             <tr>
                <th align='right'>Service Area:</th>
                <th align='right'>Union</th>
                <th align='right'>South Carolina</th>
             </tr>
             </table>
    ...into this?
    Code:
    <table><tr><th align='right'>Service Area:</th><th align='right'>Union</th><th align='right'>South Carolina</th></tr></table>
    Matt Alexander
    Alexander Site Design

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should work, assuming that input is valid HTML.
    PHP Code:
    $html preg_replace('~>\s+<~m''><'$html); 

  3. #3
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That great! Thanks.
    Matt Alexander
    Alexander Site Design


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •