note 111760 added to function.array-filter
| From: | tx at tshwarelo-leaka dot co dot za | Date: | Tue, 26 Mar 2013 09:26:50 +0000 |
| Subject: | note 111760 added to function.array-filter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194205@lists.php.net to get a copy of this message | ||
To get rid of all white space in an array without looping.
<?php
$array = array(5, " ", 2, NULL, 13, "", 7, "\n", 4,
"\t");
print_r($array);
$result = array_filter($array, create_function('$a','return
preg_match("#\S#", $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/111760
Del: integrated -- https://master.php.net/note/delete/111760/integrated
Del: useless -- https://master.php.net/note/delete/111760/useless
Del: bad code -- https://master.php.net/note/delete/111760/bad+code
Del: spam -- https://master.php.net/note/delete/111760/spam
Del: non-english -- https://master.php.net/note/delete/111760/non-english
Del: in docs -- https://master.php.net/note/delete/111760/in+docs
Del: other reasons-- https://master.php.net/note/delete/111760
Reject -- https://master.php.net/note/reject/111760
Search -- https://master.php.net/manage/user-notes.php