note 83909 deleted from function.trim by hholzgra

From: Date: Thu, 02 Aug 2012 12:27:13 +0000
Subject: note 83909 deleted from function.trim by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189660@lists.php.net to get a copy of this message
Note Submitter: aalaap at gmail dot com ---- 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".

« previous php.notes (#189660) next »