note 80822 added to function.preg-replace
| From: | MattBrennan at osu1 dot php dot net | Date: | Fri, 01 Feb 2008 21:47:12 +0000 |
| Subject: | note 80822 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135717@lists.php.net to get a copy of this message | ||
A quick function to strip excessive whitespace:
<?php
$string = "Hello. How are you?\n\nLots of whitespace.\t\t\t\tEnd.";
echo preg_replace('/(\s)+/','$1',$string);
?>
Outputs "Hello. How are you?
Lots of whitespace. End."
----
Server IP: 194.145.210.3
Probable Submitter: 90.202.211.74
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/80822
Del: integrated -- https://master.php.net/note/delete/80822/integrated
Del: useless -- https://master.php.net/note/delete/80822/useless
Del: bad code -- https://master.php.net/note/delete/80822/bad+code
Del: spam -- https://master.php.net/note/delete/80822/spam
Del: non-english -- https://master.php.net/note/delete/80822/non-english
Del: in docs -- https://master.php.net/note/delete/80822/in+docs
Del: other reasons-- https://master.php.net/note/delete/80822
Reject -- https://master.php.net/note/reject/80822
Search -- https://master.php.net/manage/user-notes.php