note 19330 deleted from function.array-filter by didou
| From: | didou@php.net | Date: | Mon, 26 Jan 2004 10:03:30 +0000 |
| Subject: | note 19330 deleted from function.array-filter by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-64198@lists.php.net to get a copy of this message | ||
Note Submitter: jonathan@inetz.com
----
Leveraging PHP functions as callbacks can be especially useful. A handy one is strlen(), as you can
use it to filter out entries that don't have values. (Sometimes if $HTTP_POST_VARS is huge, I
like to limit it down to those entries that were actually filled.)
$post_filtered = array_filter( $HTTP_POST_VARS, "strlen" );
Use trim() if some entries have whitespace:
$post_filtered = array_filter( $str_array, "trim" );