I've used the following code to create a multidimensional array:
$stats = file ("stats.log") ;
$statsData = array() ;
$i = (0) ;
// split each element of $stats into $statsData array //
while ($i < count($stats)) {
$statsData[$i] = split(",", $stats[$i]) ;
++$i ;
}
For the sake of argument, let's say the first three lines of "stats.log" contains the following:
larry,frizzy,heymoe
moe,bowlcut,whyioughtta
curly,bald,nyuck
Is there a way I can sort the $statsData array by it's second element, keeping the first and second element of each sub array with it? Say if I needed the stooge's hairstyles alphabetized, I'd want the resulting output to be:
curly,bald,nyuck
moe,bowlcut,whyioughtta
larry,frizzy,heymoe
If this is doable, are their any special concerns when sorting strings this way as opposed to numbers?
Thanks a heap!
Eric