note 52923 modified in function.trim by hholzgra

From: Date: Thu, 02 Aug 2012 12:22:28 +0000
Subject: note 52923 modified in function.trim by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189637@lists.php.net to get a copy of this message
If you want to check whether something ONLY has whitespaces, use the following:&#13;&#10;&#13;&#10;&#60;?php&#13;&#10;&#13;&#10;if (trim($foobar)==&#39;&#39;) {&#13;&#10; echo &#39;The string $foobar only contains whitespace!&#39;;&#13;&#10;}&#13;&#10;&#13;&#10;?&#62; --was-- Note that manithu's post on 29-Mar-2005 02:49 for identifying strings that only contain whitespaces will also identify strings like "0" and " 0 " as being empty. If you want to check whether something ONLY has whitespaces, use the following: <?php if (trim($foobar)=='') { echo 'The string $foobar only contains whitespace!'; } ?> http://php.net/manual/en/function.trim.php

« previous php.notes (#189637) next »