note 22002 deleted from function.trim by hholzgra

From: Date: Thu, 02 Aug 2012 12:19:08 +0000
Subject: note 22002 deleted from function.trim by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189626@lists.php.net to get a copy of this message
Note Submitter: daggillies at yahoo dot com ---- NOTE: All the above examples using ereg_replace with an escape code of \v are BROKEN! \v is NOT an escape code in PHP. Using a regexp of \v e.g. $str=ereg_replace("[\r\t\n\v]","",$str); will remove any instances of the letter 'v' from your string. So 'Activity' becomes 'Actiity'. Probably not what you want. Here is a small function I use to strip whitespace from the end of strings and squash repeated whitespace down to a single space in the middle of strings: function wsstrip(&$str) { $str=ereg_replace (' +', ' ', trim($str)); $str=ereg_replace("[\r\t\n]","",$str); } David Gillies San Jose Costa Rica

« previous php.notes (#189626) next »