note 89432 added to function.array-filter

From: Date: Sat, 07 Mar 2009 18:34:08 +0000
Subject: note 89432 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-151596@lists.php.net to get a copy of this message
I wanted a function to keep the values that were filtered out and return them separately. Basically, split the array by some callback. I wrote this for the job: function array_split($input, &$trues, &$falses, $compare) { while (($item = array_pop($input)) != NULL) { if ($compare($item)) $trues[] = $item; else $falses[] = $item; } } very simple, something I would think would be standard, and array_filter would amount to discarding the falses. ---- Server IP: 64.71.164.2 Probable Submitter: 66.253.230.52 (proxied: 216.171.21.244) ---- Manual Page -- http://www.php.net/manual/en/function.array-filter.php Edit -- https://master.php.net/note/edit/89432 Del: integrated -- https://master.php.net/note/delete/89432/integrated Del: useless -- https://master.php.net/note/delete/89432/useless Del: bad code -- https://master.php.net/note/delete/89432/bad+code Del: spam -- https://master.php.net/note/delete/89432/spam Del: non-english -- https://master.php.net/note/delete/89432/non-english Del: in docs -- https://master.php.net/note/delete/89432/in+docs Del: other reasons-- https://master.php.net/note/delete/89432 Reject -- https://master.php.net/note/reject/89432 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151596) next »