note 76117 added to function.strlen
| From: | bradmwalker at cableone dot net | Date: | Sun, 01 Jul 2007 10:48:56 +0000 |
| Subject: | note 76117 added to function.strlen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128127@lists.php.net to get a copy of this message | ||
want a predicate that tests a string for emptiness? use strlen instead of empty(). strlen only
returns a false-equivalent value for ''.
example:
// takes string_array and returns an array without any values w/empty strings
function filter_empties ($string_array) {
// note: the immensely retarded empty() function returns true on string '0'
// use strlen as empty string predicate
return count($string_array) ? array_filter ($string_array, 'strlen') : $string_array;
}
----
Server IP: 208.69.120.35
Probable Submitter: 67.60.94.208
----
Manual Page -- http://www.php.net/manual/en/function.strlen.php
Edit -- https://master.php.net/note/edit/76117
Del: integrated -- https://master.php.net/note/delete/76117/integrated
Del: useless -- https://master.php.net/note/delete/76117/useless
Del: bad code -- https://master.php.net/note/delete/76117/bad+code
Del: spam -- https://master.php.net/note/delete/76117/spam
Del: non-english -- https://master.php.net/note/delete/76117/non-english
Del: in docs -- https://master.php.net/note/delete/76117/in+docs
Del: other reasons-- https://master.php.net/note/delete/76117
Reject -- https://master.php.net/note/reject/76117
Search -- https://master.php.net/manage/user-notes.php