note 111751 added to function.array-filter

From: Date: Mon, 25 Mar 2013 12:56:06 +0000
Subject: note 111751 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-194194@lists.php.net to get a copy of this message
Well, the code below posted by anonymous does work but sometimes you also want to filter all white spaces. Here's another trick. <?php $array = array(5, " ", 2, NULL, 13, "", 7); print_r($array); $result = array_filter($array, create_function('$a','return trim($a)!="";')); print_r($result); ?> Array ( [0] => 5 [1] => [2] => 2 [3] => [4] => 13 [5] => [6] => 7 [7] => [8] => 4 [9] => ) Array ( [0] => 5 [2] => 2 [4] => 13 [6] => 7 [8] => 4 ) ---- Server IP: 69.147.83.199 Probable Submitter: 41.85.155.77 ---- Manual Page -- http://php.net/manual/en/function.array-filter.php Edit -- https://master.php.net/note/edit/111751 Del: integrated -- https://master.php.net/note/delete/111751/integrated Del: useless -- https://master.php.net/note/delete/111751/useless Del: bad code -- https://master.php.net/note/delete/111751/bad+code Del: spam -- https://master.php.net/note/delete/111751/spam Del: non-english -- https://master.php.net/note/delete/111751/non-english Del: in docs -- https://master.php.net/note/delete/111751/in+docs Del: other reasons-- https://master.php.net/note/delete/111751 Reject -- https://master.php.net/note/reject/111751 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194194) next »