How to use array_chunk () function to split arrays in PHP
This article mainly introduces the PHP how to use array_chunk () function to divide the array of related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone in this PHP how to use array_chunk () function to split the array article will have a harvest, let's take a look at it.
1. Concept
Separate an array into several arrays.
2. Grammar
Array_chunk (array,size,preserve_keys)
3. Parameters
Array
Size
Preserve_key
4. Return value
Returns a multidimensional array of numeric values, starting at 0, with each dimension containing size elements.
5. Examples
$array = ['name' = >' tom', 'age' = > 20, 3, 4, 5,' averse,'b']
Split into a group of three
$chunk_result = array_chunk ($array, 3)
Result
Array ([0] = > Array ([0] = > tom [1] = > 20 [2] = > 3) [1] = > Array ([0] = > 4 [1] = > 5 [2] = > a) [2] = > Array ( [0] = > b)) this is the end of the article on "how to split an array with the array_chunk () function in PHP" Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to divide arrays with the array_chunk () function in PHP". If you want to learn more, you are welcome to follow the industry information channel.