note 77131 deleted from function.trim by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 12:25:20 +0000 |
| Subject: | note 77131 deleted from function.trim by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189654@lists.php.net to get a copy of this message | ||
Note Submitter: lxg
----
masteremployment's solution in a function, and with preg_replace() instead of ereg_replace():
<?php
function removeWhitespace($string)
{
if (!is_string($string))
return false;
$string = preg_quote($string, '|');
return preg_replace('| +|', ' ', $string);
}
?>