note 47351 deleted from function.trim by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 12:21:17 +0000 |
| Subject: | note 47351 deleted from function.trim by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189633@lists.php.net to get a copy of this message | ||
Note Submitter: abderzack host provider hotmail dot com
----
To eliminate all the empty strings from my array, I used the array_filter, that way :
1.
I defined a function returning true iff the passed as parameter string is NOT empty.
function notEmpty($string)
{
return !empty($string);
}
2.Use array filter :
$myarray = array_filter($myarray ,"notEmpty");
That's it.
Of course, if you want to prove your mama you can write unreadable code, you can create an anonymous
function, by using the create_function, instead of declaring the function notEmpty.
Hope that will help you.