RFC karma request: array_partition()

From: Date: Thu, 22 Oct 2026 18:50:19 +0000
Subject: RFC karma request: array_partition()
Groups: php.internals 
Request: Send a blank email to internals+get-132902@lists.php.net to get a copy of this message
Hi internals, I'd like to request RFC karma on the wiki to propose a new function, array_partition(). My wiki username is: ayoubezzini The function splits an array into the elements that satisfy a callback and those that don't, in a single pass: [$adults, $minors] = array_partition($users, fn($u) => $u->age >= 18); It returns [$matching, $nonMatching], preserves keys, and takes the same $mode argument (ARRAY_FILTER_USE_KEY / ARRAY_FILTER_USE_BOTH) as array_filter(). Today the same result needs two array_filter() passes with a negated callback, or array_filter() followed by array_diff_key(). The same operation exists as Laravel's Collection::partition(), Ruby's Enumerable#partition, Kotlin's partition and Rust's Iterator::partition. An implementation with tests is available as a draft PR: https://github.com/php/php-src/pull/24568 I'll open the formal [RFC] discussion thread once the wiki page is up. Thanks, Ayoub Ezzini

« previous php.internals (#132902) next »