note 107646 added to function.trim
| From: | RodrigoCunille | Date: | Thu, 23 Feb 2012 16:30:32 +0000 |
| Subject: | note 107646 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186322@lists.php.net to get a copy of this message | ||
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
?>
----
Server IP: 148.206.80.9
Probable Submitter: 201.103.132.29
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- https://master.php.net/note/edit/107646
Del: integrated -- https://master.php.net/note/delete/107646/integrated
Del: useless -- https://master.php.net/note/delete/107646/useless
Del: bad code -- https://master.php.net/note/delete/107646/bad+code
Del: spam -- https://master.php.net/note/delete/107646/spam
Del: non-english -- https://master.php.net/note/delete/107646/non-english
Del: in docs -- https://master.php.net/note/delete/107646/in+docs
Del: other reasons-- https://master.php.net/note/delete/107646
Reject -- https://master.php.net/note/reject/107646
Search -- https://master.php.net/manage/user-notes.php