note 67126 added to function.empty
| From: | KarlJung at osu1 dot php dot net | Date: | Sat, 03 Jun 2006 16:03:31 +0000 |
| Subject: | note 67126 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-113126@lists.php.net to get a copy of this message | ||
This function I did, works like empty(), but doesn't consider zero (0) as empty.
Also, considers as empty, a string containing only blank spaces, or "\n", "\t",
etc.
function my_empty($val)
{
$result = false;
if (empty($val))
$result = true;
if (!$result && (trim($val) == ""))
$result = true;
if ($result && is_numeric($val) && $val == 0)
$result = false;
return $result;
}
Values considered as EMPTY:
$val = "";
$val = " ";
$val = " \t \n ";
$val = array();
$val = false;
$val = null;
Values considered NOT EMPTY:
$val = "0";
$val = intval(0);
$val = floatval(0);
----
Server IP: 201.216.232.3
Probable Submitter: 200.125.99.160
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- http://master.php.net/note/edit/67126
Del: integrated -- http://master.php.net/note/delete/67126/integrated
Del: useless -- http://master.php.net/note/delete/67126/useless
Del: bad code -- http://master.php.net/note/delete/67126/bad+code
Del: spam -- http://master.php.net/note/delete/67126/spam
Del: non-english -- http://master.php.net/note/delete/67126/non-english
Del: in docs -- http://master.php.net/note/delete/67126/in+docs
Del: other reasons-- http://master.php.net/note/delete/67126
Reject -- http://master.php.net/note/reject/67126
Search -- http://master.php.net/manage/user-notes.php