>
Download This Plugin | |
Download Elegant Themes | |
Name | array_partition |
Version | 1.2.2 |
Author | Scott Reilly |
Rating | 0 |
Last updated | 2015-02-12 07:10:00 |
Downloads |
739
|
Download Plugins Speed Test plugin for Wordpress |
Home page PageSpeed score has been degraded by 0%, while Post page PageSpeed score has been degraded by 0%
array_partition plugin added 3 bytes of resources to the Home page and 16 bytes of resources to the sample Post page.
array_partition plugin added 0 new host(s) to the Home page and 0 new host(s) to the sample Post page.
Great! array_partition plugin ads no tables to your Wordpress blog database.This plugin provides the PHP function c2c_array_partition()
to split an array into any number of sub-arrays, suitable for creating evenly distributed, vertically filled "columns". Also known as "chunking" or "partitioning".
For example:
$topics = array( "aardvark", "bear", "cat", "dog", "emu", "fox", "gnu", "hippo", "ibis", "jackal" );
print_r( c2c_array_partition( $topics, 4 ) );
Yields:
Array
(
[0] => Array
(
[0] => ant
[1] => bear
[2] => cat
)
[1] => Array
(
[0] => dog
[1] => emu
[2] => fox
)
[2] => Array
(
[0] => gnu
[1] => hippo
)
[3] => Array
(
[0] => ibis
[1] => jackal
)
)
Note the array elements are distributed into the requested 4 "columns" as evenly as possible.
The function will fill as many partitions as requested, as long as there are enough elements in the array to do so. Any remaining unfilled partitions will be represented as empty arrays.
In contrast, using PHP's built-in array_chunck()
as such:
print_r( array_chunk( $topics, 4 ) );
Yields:
Array
(
[0] => Array
(
[0] => aardvark
[1] => bear
[2] => cat
[3] => dog
)
[1] => Array
(
[0] => emu
[1] => fox
[2] => gnu
[3] => hippo
)
[2] => Array
(
[0] => ibis
[1] => jackal
)
)
It can be sent an array of any data types or objects.
Links: Plugin Homepage | Plugin Directory Page | Author Homepage