Morri Posted September 14, 2006 Share Posted September 14, 2006 I have a multi-dimensional array in the following format:Array( [key1] => Array ( [subkey1] => name1 [subkey2] => ... [subkey3] => ... [subkey4] => ... [subkey5] => ... [subkey6] => ... [subkey7] => ... ) [key2] => Array ( [subkey1] => name2 [subkey2] => ... [subkey3] => ... [subkey4] => ... [subkey5] => ... [subkey6] => ... [subkey7] => ... )Is there anyway i can sort the array by a subkey value (name# for instance)?I'd be greatful for any help.Thanks, John Quote Link to comment Share on other sites More sharing options...
Morri Posted September 14, 2006 Author Share Posted September 14, 2006 I really should browse the net a bit before i post... ::) :-[More or less found the answer then i modified it to get the code below.[code]function compare($x, $y){ if ( $x[subkey1] == $y[subkey1] ) return 0; else if ( $x[subkey1] < $y[subkey1] ) return -1; else return 1;}uasort($fonts, 'compare');[/code]Anyway back to coding the rest of this thing... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.