RE: [PHP-WIN] Something like trim()

From: Date: Sat, 01 Feb 2003 10:50:25 +0000
Subject: RE: [PHP-WIN] Something like trim()
Groups: php.windows 
Request: Send a blank email to php-windows+get-18287@lists.php.net to get a copy of this message
Or just $cleanstring = ereg_replace("[ \t\n]+"," ",trim($dirtystring)); Jill -----Original Message----- From: Cam Dunstan [mailto:cam@norex.com.au] Sent: Saturday, February 01, 2003 2:24 AM To: php-windows@lists.php.net Subject: [PHP-WIN] Something like trim() Cybot, try this .... function string_dryclean($dirtystring) { $cleanstring = str_replace("\n", " ", $dirtystring); $cleanstring = trim(str_replace("\t", " ", $cleanstring)); do { $cleanstring = str_replace(" ", " ", $cleanstring); } while (strpos($cleanstring, " ") > 0); return $cleanstring; } use it like this... $ugly_evil_string = " hello \n\n \n\t world \n\n\t "; $decent_law_abiding_string = string_dryclean($ugly_evil_string);

« previous php.windows (#18287) next »