PHP array_chunk Function Example
Hello Friends,
Now let's see example of how to use array_chunk function in php. This is a short guide on php if array_chunk function. We will use array_chunk function splits an array into chunks of new arrays. Here you will learn how to use array_chunk in php. The last chunk may contain less than size elements. Let's get started with array_chunk function in php.
Here i will give you example of how you can use array_chunk function in php.
Syntax
array_chunk(input_array, size, preserve_keys)
Example
<!DOCTYPE html>
<html>
<head>
<title>PHP array_chunk Function Example - NiceSnippets.com?</title>
</head>
<body>
<?php
$input_array = array('php', 'laravel','java','html');
print_r(array_chunk($input_array,2));
?>
</body>
</html>
Output:
Array ( [0] => Array ( [0] => php [1] => laravel ) [1] => Array ( [0] => java [1] => html ) )
It will help you....
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example