note 125632 added to function.array-chunk
| From: | Anonymous@php.net | Date: | Mon, 28 Dec 2020 16:21:09 +0000 |
| Subject: | note 125632 added to function.array-chunk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216030@lists.php.net to get a copy of this message | ||
Most easy way split array to parts
<?php
$arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
print_r(array_chunk($arr, ceil(count($arr) / 2)));
// return: [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]
print_r(array_chunk($arr, ceil(count($arr) / 3)));
// return: [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10]]
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.165 (proxied: 188.119.40.62)
----
Manual Page -- http://php.net/manual/en/function.array-chunk.php
Edit -- https://master.php.net/note/edit/125632
Del: integrated -- https://master.php.net/note/delete/125632/integrated
Del: useless -- https://master.php.net/note/delete/125632/useless
Del: bad code -- https://master.php.net/note/delete/125632/bad+code
Del: spam -- https://master.php.net/note/delete/125632/spam
Del: non-english -- https://master.php.net/note/delete/125632/non-english
Del: in docs -- https://master.php.net/note/delete/125632/in+docs
Del: other reasons-- https://master.php.net/note/delete/125632
Reject -- https://master.php.net/note/reject/125632
Search -- https://master.php.net/manage/user-notes.php