News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Chris Shiflett's Blog:
Sorting Multi-Dimensional Arrays in PHP
July 01, 2011 @ 09:48:26

In a sort of "remind himself later" kind of post, Chris Shiflett has shared a quick example of a common task PHP developers face sorting a multi-dimensional array.

Every time I need to sort a multi-dimensional array in PHP, I have to remind myself how to do it. It's not quite as quick and easy to look up as most things, so I'm going to blog a quick example. I've always felt like there must be a better way to do this, so please let me know if there is, and I'll update this post accordingly.

His method sorts a multi-dimensional array of user data using the array_multisort function together with a list of the usernames in each record. In the comments, people recommend using usort instead with a callback+closure combo that keeps things nice and clean.

0 comments voice your opinion now!
sort multidimensional array hint


blog comments powered by Disqus

Similar Posts

Community News: Packagist Latest Releases for 07.20.2013

Site News: Job Postings for the week of 07.19.2009

Community News: Latest PECL Releases for 03.01.2011

Community News: Latest PECL Releases for 06.11.2013

Site News: Popular Posts for the Week of 01.22.2010


Community Events





Don't see your event here?
Let us know!


community list framework threedevsandamaybe application interview api library language code laravel project podcast developer series bugfix release wordpress introduction configure

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework