note 90171 modified in function.trim by danbrown

From: Date: Wed, 08 Apr 2009 21:18:17 +0000
Subject: note 90171 modified in function.trim by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152978@lists.php.net to get a copy of this message
I made this function to trim texts. Removes al double horizontal and vertical whitespace chars. <?php function trimText($str) { $str = trim($str); $str = preg_replace('/\h+/', ' ', $str); $str = preg_replace('/\v{3,}/', PHP_EOL.PHP_EOL, $str); return $str; } ?> --was-- I made this function to trim texts. Removes al double horizontal and vertical whitespace chars. function trimText($str) { $str = trim($str); $str = preg_replace('/\h+/', ' ', $str); $str = preg_replace('/\v{3,}/', PHP_EOL.PHP_EOL, $str); return $str; } http://php.net/manual/en/function.trim.php

« previous php.notes (#152978) next »