Close

December 29, 2011

How to Sort Multidimensional Arrays Using PHP

In this video, you’ll learn how to sort multidimensional arrays in PHP. You’ll not only learn basic sorting using array_multisort(), but you’ll also see a more advanced custom function for sorting multidimensional arrays by a specific key.

Multidimensional arrays can be one of the more confusing parts about learning PHP, but this video will help you get your head around it and give you some tools for sorting your multidimensional arrays that are simple and straight-forward.

6 Comments on “How to Sort Multidimensional Arrays Using PHP

Olusola Osineye
May 22, 2013 at 9:55 pm

I've learnt a lot from your YouTube tutorials. You are awesome. Thanks.

Reply
John Morris
May 22, 2013 at 9:58 pm

Haha thanks! That’s what I like to hear! 🙂

Reply
m.waqas afzal
May 17, 2014 at 10:20 pm

hai john ! can i get the codes of your videos on youtube…

Reply
Rayvn
March 19, 2018 at 7:26 pm

Hi John, I left a comment on your YouTube channel but wanted to thank you again. I was messing with an identical problem for a few days. Per my youtube comment, I had to add the keys as indices since the numerical indices were causing issues. Thank you again.

Reply
John Morris
March 20, 2018 at 2:11 pm

No problem. Like I said over there, thanks for watching and posting your tweaks.

Reply
colinmyphotoclub
September 25, 2018 at 11:50 pm

Thanks John
How do I extend this to sort by multiple keys? e.g age, then name.
Colin

Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.