note 83909 added to function.trim

From: Date: Wed, 18 Jun 2008 06:42:56 +0000
Subject: note 83909 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-140552@lists.php.net to get a copy of this message
If you want to remove all excessive spaces and leave just a single one, like the way HTML text gets rendered in the browser, this function (modified from one posted here earlier) will work: function str_squeeze($test) { return trim(ereg_replace( ' +', ' ', $test)); } The result is that a string such as "hello___how_are__you_" (where the _ is a space) will result in a more sane "hello_how_are_you". ---- Server IP: 203.199.69.133 Probable Submitter: 202.87.54.162 ---- Manual Page -- http://www.php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/83909 Del: integrated -- https://master.php.net/note/delete/83909/integrated Del: useless -- https://master.php.net/note/delete/83909/useless Del: bad code -- https://master.php.net/note/delete/83909/bad+code Del: spam -- https://master.php.net/note/delete/83909/spam Del: non-english -- https://master.php.net/note/delete/83909/non-english Del: in docs -- https://master.php.net/note/delete/83909/in+docs Del: other reasons-- https://master.php.net/note/delete/83909 Reject -- https://master.php.net/note/reject/83909 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140552) next »