note 47351 added to function.trim
| From: | abderzackhostproviderhotmaildotcom at osu1 dot php dot net | Date: | Fri, 12 Nov 2004 15:44:52 +0000 |
| Subject: | note 47351 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-80442@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47351
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47351&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47351&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47351&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47351&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47351&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47351&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47351&report=yes
Search -- http://master.php.net/manage/user-notes.php