1

Ive never used the sort function that much and need a hand here.

I have this weird looking array:

array (size=1)
  'MostErrors' => 
    array (size=2)
      2048 => 
        array (size=1)
          'Declaration of ADODB_mysqli::MetaIndexes() should be compatible with ADOConnection::MetaIndexes($table, $primary = false, $owner = false)' => 
            array (size=1)
              'Count' => int 5
      8 => 
        array (size=4)
          'Undefined index: VersionKey' => 
            array (size=1)
              'Count' => int 3
          'Undefined index: PluginBestseller' => 
            array (size=1)
              'Count' => int 3
          'Undefined index: PluginLastPurchased' => 
            array (size=1)
              'Count' => int 3
          'Undefined index: PluginLastAdded' => 
            array (size=1)
              'Count' => int 3

How do I Sort it correctly, that the Error with the highest count is at the top?

8, 2048 are the constants of PHP E_WARNING,E_ERROR,.. I want to have statistics which error/warning apprear the most

Ive tried usort and uasort, but I can't use echo in the callbacks .. why ever, I cannot work like that..

Moe
  • 43
  • 3
  • 1
    please visit this stackflow question. hope it help. http://stackoverflow.com/questions/2699086/sort-multidimensional-array-by-value-2 use method aasort(urarray, "count"); – Hasina Jun 07 '13 at 12:42
  • Slightly off-topic here, but if you're trying to use `echo` in a `usort` callback then you are really not understanding what `usort` does. The callback function for `usort` should simply test the two incoming values and return a +1, -1 or 0 result according to which one should be sorted higher than the other. There should never be a need to `echo` inside this function. – Spudley Jun 07 '13 at 12:58
  • Thanks for the link so far. @Spudly, Ive understood this function. I wanted the echo just for debugging, not for managing the data :) – Moe Jun 07 '13 at 14:19
  • might not be helpful, but I've used array_flip to swap values for keys then used ksort() to achieve something similar. – Karl Jan 24 '14 at 23:53

0 Answers0