PHP Sort Multi Dimension array
Go to solution
Solved by fizzlesticks,
Use usort
The first parameter is the array and the second parameter is a function that takes 2 arguments which are the 2 values being compared (arrays in your case.)
The function needs to return 0 if 2 objects are equal, 1 if the first parameter is greater and -1 if the first parameter is less. If you're using PHP 7 the function will look something like:
usort($your_array, function($a, $b) { return $a[1] <=> $b[1]; });
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now