Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 510 Bytes

File metadata and controls

29 lines (19 loc) · 510 Bytes

partition

Description

Partition an array into arrays with size elements preserving its keys. The last portion may contain less than size elements.

Parameters

size
The size of each portion.
coll
Coll to be partitioned.

Examples

Partition an array:

<?php

use function Lambdish\Phunctional\partition;

$coll = [1, 2, 3, 4, 5, 6, 7];

partition(2, $coll);

// => [[0 => 1, 1 => 2], [2 => 3, 3 => 4], [4 => 5, 5 => 6], [6 => 7]]