News Feed
Sections




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

Bjarte Karlsen's Blog:
Sorting with uasort
October 30, 2006 @ 13:25:00

Bjarte Karlsen has a handy tip posted to his blog today - one array function to keep in mind when doing more than just the basic sorting - uasort.

Problem: You have an array of objects or a multidimentional arrays where the key of the first array has some meaning. It could be a id or something else. You want to sort the array and maintain the key=>value association.

Some may then proceed to loop the array and sort it in a loop, however there is a easier method.

He reminds us that the fucntion allows you to take in the array and, based on a user-defined function, sort the results, keeping the association between the keys and values.

0 comments voice your opinion now!
sorting uasort user defined function maintian assoication sorting uasort user defined function maintian assoication


blog comments powered by Disqus

Similar Posts

Pierre-Alain Joye's Blog: Prominent PHP Users (developers), do your homework or be humble/keep quiet

Blog.szajbe.pl: Not so obvious behavior of $uses in CakePHP

SecurityReason.com: PHP 5.2.4 Released...unpatched

Scott Johnson\'s Blog: The Overhead of PHP is_ functions?

AnyExample.com: 5 useful PHP functions for MySQL data fetching


Community Events





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


series laravel library symfony framework security introduction composer podcast list release artisanfiles language interview version opinion conference tool community voicesoftheelephpant

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