note 107646 deleted from function.trim by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 12:32:47 +0000 |
| Subject: | note 107646 deleted from function.trim by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189681@lists.php.net to get a copy of this message | ||
Note Submitter: Rodrigo Cunille
----
Here is a way to eliminate all the intermediate whitespaces in a string, but leaving just one
whitespace in order to keep data such as names in a correct order.
example:
<?php
$text = "john doe doe";
//here is the function
while(substr_count($text," ") != 0){
$text = str_replace(" "," ",$text);
}
//The result would be: john doe doe
?>