Old fashion way
$groupTrue = $groupFalse = [];
foreach ($items as $item) {
if (some_logic_function($item)) {
$groupTrue[] = $item;
} else {
$groupFalse[] = $item;
}
}
New way
list($groupTrue, $groupFalse) = collect($items)
->partition(fn ($item) => some_logic_function($item))
->map(fn ($group) => $group->values());
tip: Using the last map then values to reset indexing of 2 groups after spliting.