Skip to content
Partition an array into multiple arrays using PHP.
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
test1.php
test2.php

README.md

Array Partition PHP

Partition an array into multiple arrays using PHP.

Example

Input

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

Output

Array (
    [0] => Array (
            [0] => 1
            [1] => 2
            [2] => 3
        )
    [1] => Array (
            [0] => 4
            [1] => 5
        )
    [2] => Array (
            [0] => 6
            [1] => 7
        )
)
You can’t perform that action at this time.