note 76117 modified in function.strlen by danbrown
| From: | danbrown@php.net | Date: | Thu, 12 Feb 2009 03:15:15 +0000 |
| Subject: | note 76117 modified in function.strlen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150536@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:
<?php
// 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;
}
?>
--was--
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;
}
http://php.net/manual/en/function.strlen.php