News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
Felix Geisendorfer's Blog:
Sorting Challenge
October 26, 2007 @ 08:42:00

Felix Geisendorfer has a quick little sorting example posted today showing on way to sort a multi-dimensional array.

Quick challenge, lets say you have an array and you want to iterate through your products by [the key of each subarray in $products] Product.ordering ASC. Whats the fastest way to do this?

His solution involves using an array_flip call on the extracted information (using Set::extract), ordering it with ksort and pushing the values back into the $product array in the right order.

Check out the comments for more examples including ones that make use of array_multisort.

0 comments voice your opinion now!
sort challenge arraymultisort arrayflip foreach array sort challenge arraymultisort arrayflip foreach array



Similar Posts

DevShed: The Switch Statement and Arrays

Paul Jones' Blog: New PDO Behavior In PHP 5.2.1

Felix Geisendorfer's Blog: Sorting Challenge

Felix Geisendorfer's Blog: Sorting Challenge

Jacob Santos' Blog: My Love For Array Object Idiocy


Community Events







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


application mysql releases book zendframework PEAR database ajax zend PHP5 framework package release job developer security code cakephp conference example

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