ANIL KUMAR PANIGRAHI 's Blog

How to remove consecutive whitespaces using php?

Posted by: Anil Kumar Panigrahi in: ● January 19, 2010

Following script will work for remove the newline and remove the consecutive white spaces

function remW( $content )
{
$content = trim(ereg_replace(“\n|\r|\r\n|\n\r”, ”, preg_replace(‘/\s+/’, ‘ ‘, $content)));
return $content;
}

Share on Twitter

1 Comment to "How to remove consecutive whitespaces using php?"

1 | VentSmart Dryer Vent

26 de January de 2010 to ● 2:55 am

Thanks been looking for that code

Write Comment

About Me

  Anil Kumar Panigrahi
  Software Engineer (PHP)
  Blogger & Founder of Anil Labs
  Baruva, India

You can share with me . . .

My Own Contributions

1) First contribution for codeigniter framework ( multi language support using google translate API ). we can get files from http://github.com/nyros/codeigniter_multilanguage


2) Audio and Video Streaming using FFMpeg and PHP -complete doc file : http://www.docstoc.com/docs/8300349/Audio-and-Video-Streaming

Twitter Updates

Follow me @anil2u
  • http://www.google.co.uk/ logo is changing with mouse move . . . - posted on 07/09/2010 10:57:33
  • True enemies are real friends . . . - posted on 06/09/2010 10:15:29
  • Just watched nice movie " Madrasapattinam ". - posted on 05/09/2010 16:20:48
  • We will always be thankful to our teacher for all the hard work and efforts they have put in, for educating us.- Happy teachers Day . . . :) - posted on 05/09/2010 05:39:13
  • Working on shipping cost functionality (UPS and USPS) for oscommerce shopping cart - posted on 01/09/2010 09:40:03