note 51398 added to function.trim
| From: | manithu at osu1 dot php dot net | Date: | Tue, 29 Mar 2005 19:49:56 +0000 |
| Subject: | note 51398 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87159@lists.php.net to get a copy of this message | ||
An faster (and eleganter) way than using regular expressions to check if a string only contains
whitespaces is to use trim().
Example:
<?php
if (!trim($foobar)) {
echo 'The string $foobar is empty!';
}
?>
I hope this helps somebody.
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51398
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51398&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51398&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51398&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51398&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51398&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51398&report=yes
Search -- http://master.php.net/manage/user-notes.php