Convert Multiple Spaces To a Single Space

Written by Chris on May 29, 2007 – 8:42 pm -

Sometimes you want to sanitise a block of text or input by removing consecutive multiple whitespace entries from it, replacing them with a single space. This php code will allow you to do just that:


$message = preg_replace(‘/ss+/’, ‘ ‘, $message);



Popularity: 3% [?]

Sphere: Related Content

Related posts on coderchris.com:

  1. Firefox Fail
    OK.... Let's make history..... LOL..... Oh Well... Popularity: 3% [?]SHARETHIS.addEntry({ title: "Convert Multiple Spaces...
  2. Where Did All The Disk Space Go??
    When I converted my laptop to a dual boot system, I did so by...
  3. Holy Keyword Loaded Sub-domains Batman!
    After finding this in a random search on Google for CSV to SQL converters...
  4. 2 New Facebook Apps Begun
    Today I have started writing 2 new Facebook applications, Doomsday Device and Game Stats....
  5. How to filter user submitted data easily in PHP?
    How to filter user submitted data easily in PHP? Posted using ShareThis Firstly, as...


Posted in Uncategorized | Trackback |

Leave a Comment

RSS

  • Translator

    English flagChinese (Simplified) flagChinese (Traditional) flagDutch flagFrench flagGerman flag
    Greek flagItalian flagJapanese flagKorean flagPortuguese flagRussian flag
    Spanish flag     
    By N2H
  • Also Find Me On

    Delicious  Digg  Facebook  Flickr  FriendFeed  Last.fm  LinkedIn  LiveJournal  Ma.gnolia  MyBlogLog  MySpace  StumbleUpon  Technorati  Twitter  YouTube  



  • Find job
  • Loans
  • Online Advertising
  • Bankruptcy
  • Mortgage