note 111751 deleted from function.array-filter by aharvey

From: Date: Tue, 26 Mar 2013 16:05:54 +0000
Subject: note 111751 deleted from function.array-filter by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-194215@lists.php.net to get a copy of this message
Note Submitter: tx at tshwarelo-leaka dot co dot za ---- 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 )

« previous php.notes (#194215) next »