array_partition

array_partition

Wordpress plugin

Install on Wordpress

App Details

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_chunk() 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 | GitHub | Author Homepage

Examples

<?php $topics = array( "ant", "bear", "cat" ); print_r( c2c_array_partition( $topics, 5 ) ); ?> 

=>

Array ( [0] => Array ( [0] => ant ) [1] => Array ( [0] => bear ) [2] => Array ( [0] => cat ) [3] => Array ( ) [4] => Array ( ) ) 

Also see Description section for another example. Definitely check out the packaged unit test file as it contains various examples.

Pricing

Starting from $0 per month.

Check Out the Announcements Widget

By Common Ninja

AnnouncementsTry For Free!

App Info

Rating

Reviewers

No reviews

Tags

array
columns
partitioning

Developed By

Scott Reilly

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Maps

Maps plugins for Wordpress

Translation

Translation plugins for Wordpress

Chat

Chat plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Contact

Contact plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Forms

Forms plugins for Wordpress

Comments

Comments plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Comments

Comments plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Video Player

Video Player plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Security

Security plugins for Wordpress

Ads

Ads plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Membership

Membership plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Announcements for Wordpress logo

Announcements

Add announcements to your site to share important updates, keep visitors informed, and guide them toward actions that support engagement and conversions.

Scores Board for Wordpress logo

Scores Board

Show rankings and performance data on your site with a customizable scores board that motivates participation and keeps users engaged.

Card Slider for Wordpress logo

Card Slider

Showcase content with a card slider that presents images, text, and buttons in a smooth, customizable layout to keep visitors engaged.

Event Listings for Wordpress logo

Event Listings

Create event listings with an events board widget that displays upcoming activities clearly, helps visitors discover events, and supports easy management.

Testimonials Slider for Wordpress logo

Testimonials Slider

Add a testimonials slider to your site to showcase real customer feedback, build credibility, and increase trust that leads to higher conversions.

Petition Form for Wordpress logo

Petition Form

Gather supporter signatures with a petition form that collects entries, saves submissions, sends notifications, and helps you drive meaningful change efficiently.

Spinning Wheel for Wordpress logo

Spinning Wheel

Add an interactive spinning wheel to offer prizes, capture leads, and drive user engagement through gamified rewards.

Cookies Consent Bar for Wordpress logo

Cookies Consent Bar

Display a cookies consent bar that explains usage and supports GDPR compliance, enhancing user trust and legal clarity.

RSS Feed Slider for Wordpress logo

RSS Feed Slider

Show RSS feed updates with an RSS feed slider that auto updates, displays posts in a smooth layout, and keeps visitors engaged.

Animated Headline for Wordpress logo

Animated Headline

Add animated headlines to draw attention to key messages and improve user engagement through visual emphasis.

Website Search for Wordpress logo

Website Search

Add a Google powered search bar that delivers relevant results, improves navigation, and helps visitors find content fast.

Social Media Links for Wordpress logo

Social Media Links

Use social media links with sticky buttons that keep your profiles visible, boost engagement, and help promote your content more effectively across your site.

More plugins

plugins You Might Like

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms