How can I sort a multidimensional array using php?

Use usort : function sortIt( $a, $b ){ if( $a'ratingVal' == $b'ratingVal' ) return 0; return ( $a'ratingVal.

Use usort: function sortIt( $a, $b ){ if( $a'ratingVal' == $b'ratingVal' ) return 0; return ( $a'ratingVal.

Thank you sir :) – learner Oct 27 '10 at 11:31 +1 (a) because your code is the way to do this and (b) because I stole it for my answer! – lonesomeday Oct 27 '10 at 11:45 1 Any reason you didn't use function sortIt($a, $b) {return $b'ratingVal'-$a'ratingVal';}? – outis Oct 27 '10 at 13:15.

If you retrieve this data from mysql database (as I see, mysql tag is specified), you may use ORDER BY statement in your query. If this is not suitable, you'll have to implement comparison function and use usort() function.

You've tagged your code "php5.3", so I'm going to give a 5.3-specific answer. Adapting Harmen's code: usort( $yourArray, function($a, $b) { if( $a'ratingVal' == $b'ratingVal' ) return 0; return ( $a'ratingVal.

Sorry sir I am using php 5.2.6 – learner Oct 27 '10 at 10:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions