Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections.
Closure $p The predicate on which to partition.:
array An array with two elements. The first element contains the collection of elements where the predicate returned TRUE, the second element contains the collection of elements where the predicate returned FALSE.
Overrides Collection::partition
public function partition(Closure $p) {
$coll1 = $coll2 = array();
foreach ($this->_elements as $key => $element) {
if ($p($key, $element)) {
$coll1[$key] = $element;
}
else {
$coll2[$key] = $element;
}
}
return array(
new static($coll1),
new static($coll2),
);
}