Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

PHP array_chunk() example

PHP array_chunk() — Split an Array into chunks. Chunks an array into arrays with size elements. The last chunk may contain less than size elements.

Syntax:

array_chunk ( array $array , int $size [, bool $preserve_keys = FALSE ] ) : array

Returns a multidimensional numerically indexed array, starting with zero, with each dimension containing size elements.

Example #1 array_chunk() example


The above example will output:

Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [0] => c
            [1] => d
        )

    [2] => Array
        (
            [0] => e
        )

)
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [2] => c
            [3] => d
        )

    [2] => Array
        (
            [4] => e
        )

)

The post PHP array_chunk() example appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

PHP array_chunk() example

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×