note 70666 added to function.array-filter
| From: | klaproth at creative-mindworks dot de | Date: | Mon, 23 Oct 2006 14:13:45 +0000 |
| Subject: | note 70666 added to function.array-filter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119012@lists.php.net to get a copy of this message | ||
As long as the array's keys are irrelevant, there is a simple way to remove blank values from
the array, after filtering has been applied. The following example is used to remove all strings
from an array that have a length of less than 4 characters.
<?php
function validElement($element) {
return strlen($element) > 3;
}
$filtered_array = array_values(array_filter($input_array, "validElement"));
?>
----
Server IP: 212.124.37.9
Probable Submitter: 195.39.226.70 (proxied: 10.0.8.122)
----
Manual Page -- http://www.php.net/manual/en/function.array-filter.php
Edit -- https://master.php.net/note/edit/70666
Del: integrated -- https://master.php.net/note/delete/70666/integrated
Del: useless -- https://master.php.net/note/delete/70666/useless
Del: bad code -- https://master.php.net/note/delete/70666/bad+code
Del: spam -- https://master.php.net/note/delete/70666/spam
Del: non-english -- https://master.php.net/note/delete/70666/non-english
Del: in docs -- https://master.php.net/note/delete/70666/in+docs
Del: other reasons-- https://master.php.net/note/delete/70666
Reject -- https://master.php.net/note/reject/70666
Search -- https://master.php.net/manage/user-notes.php