Friday, January 2, 2009

Remove Whitespaces Using Regular Expression

To remove multiple occurences of whitespace characters in a string to convert them all into single spaces, use this:

$text = preg_replace('/\s+/', ' ', $text);
?>

No comments:

Post a Comment

Yahoo! News: Technology News