English [tʃʌŋk] US [tʃʌŋk]

n. A thick piece; (something) a considerable amount or part; a strong, strong horse

Plural: chunks

php array_chunk() function syntax

Function:Split the array into new array blocks.

Syntax:array_chunk(array,size,preserve_key)

Parameters:

Parameter Description
array Required. Specifies the array to use.
size Required. An integer value specifying how many elements each new array contains.
preserve_key Optional. Possible values: true - retain the key names from the original array. false - default. Each result array uses a new array index starting from zero.

Description:Split the array into new array blocks. The number of cells in each array is determined by the size parameter. The last array may have a few fewer elements. The optional parameter preserve_key is a Boolean value that specifies whether the elements of the new array have the same keys as the original array (for associative arrays), or new numeric keys starting from 0 (for indexed arrays). The default is to assign new keys.

php array_chunk() function example


Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [0] => Array ( [0] => 灭绝 [1] => 无忌 ) [1] => Array ( [0] => 西门 [1] => peter ) )


 25,"无忌" => 20,"西门" => 27,"peter" => 37); print_r(array_chunk($age,2,true)); ?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Array ( [0] => Array ( [灭绝] => 25 [无忌] => 20 ) [1] => Array ( [西门] => 27 [peter] => 37 ) )