=== array_partition === Contributors: coffee2code Donate link: http://coffee2code.com/donate Tags: columns, array, partitions, layout, coffee2code Requires at least: 1.2 Tested up to: 3.3 Stable tag: 1.1.2 Version: 1.1.2 Adds function c2c_array_partition() to split an array into N number of evenly distributed partitions (useful for splitting a list into columns). == Description == Adds function `c2c_array_partition()` to split an array into N number of evenly distributed partitions (useful for splitting a list into columns). This plugin provides a PHP function 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( "ant", "bear", "cat", "dog", "emu", "frog", "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] => frog ) [2] => Array ( [0] => gnu [1] => hippo ) [3] => Array ( [0] => ibis [1] => jackal ) )` 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] => ant [1] => bear [2] => cat [3] => dog ) [1] => Array ( [0] => emu [1] => frog [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](http://coffee2code.com/wp-plugins/array_partition/) | [Author Homepage](http://coffee2code.com) == Installation == 1. Unzip `array_partition.zip` inside the `/wp-content/plugins/` directory (or install via the built-in WordPress plugin installer) 1. Activate the plugin through the 'Plugins' admin menu in WordPress 1. Use the `c2c_array_partition()` function in your template(s) or code as desired. == Examples == `` => `Array ( [0] => Array ( [0] => ant ) [1] => Array ( [0] => bear ) [2] => Array ( [0] => cat ) [3] => Array ( ) [4] => Array ( ) )` Also see Description section for another example. == Frequently Asked Questions == = Why not use PHP's built-in `array_chunk()`? = `array_chunk()` allows you to specify the number of elements per partition, not how many partitions you want. (See Description.) == Changelog == = 1.1.2 = * Note compatibility through WP 3.3+ * Tweak to plugin description * Minor additional documentation * Minor documentation reformatting (spacing) = 1.1.1 = * Note compatibility through WP 3.2+ * Minor code formatting changes (spacing) * Fix plugin homepage and author links in description in readme.txt = 1.1 = * Rename `array_partition()` to `c2c_array_partition()` (but maintain a deprecated version for backwards compatibility) * Add link to plugin homepage to description in readme.txt = 1.0.3 = * Note compatibility through WP 3.1+ * Update copyright date (2011) = 1.0.2 = * Wrap function in if (function_exists()) check * Note compatibility with WP 3.0+ * Remove docs from top of plugin file (all that and more are in readme.txt) * Remove trailing whitespace in header docs * Add Upgrade Notice section to readme.txt = 1.0.1 = * Add PHPDoc documentation * Note compatibility with WP 2.9+ * Update copyright date = 1.0 = * Initial release == Upgrade Notice == = 1.1.2 = Trivial update: noted compatibility through WP 3.3+ and minor documentation formatting changes (spacing) = 1.1.1 = Trivial update: noted compatibility through WP 3.2+ and minor code formatting changes (spacing) = 1.1 = Minor update: deprecated 'array_partition()' in favor of 'c2c_array_partition()'; added link to plugin homepage in readme.txt = 1.0.3 = Trivial update: noted compatibility through WP 3.1+ and updated copyright date = 1.0.2 = Minor update. Highlights: added if(function_exists()) check around array_partition(); minor text reorganization; added verified WP 3.0 compatibility.