PHP version 4.2.2
I sure hope that I can get somebody to help me figure this one out. I have a multi-dimensional array that I need to sort. Here is the code that I have so far:
function gettourndivs(){
GLOBAL $sea_id,$PHP_SELF;
$result=get_mysql_query("SELECT * FROM `games` WHERE sea_id = '$sea_id' AND deleted != '1'
GROUP BY div_id ORDER BY `type`");
$i="0";
while(($row=mysql_fetch_object($result))){
$divname=getdivisionname($row->div_id);
$array[$i][divid]=$row->div_id;
$array[$i][divname]=$divname;
$array[$i++][type]=$row->type;
}
reset($array);
// I need it to sort the array on the divname field here before going to the output.
// and instead of it doing it by the $ii, it should ouput in the correct alphabetic order of the "divname" field.
for($ii=0;$ii<$i;$ii++){
echo "$ii," . $array[$ii][divid].",";
echo $array[$ii][divname].",";
echo $array[$ii][type] . "<br>\n";
}
}

Here is the output: and I need to sort it on the third field so that it would be in alphabetic order, but keeping the other items on that line when it moves to the correct position.
0,91,Mens Open ,0
1,20,U11 Boys ,0
2,65,U17-19 Boys ,0
3,30,U12 Boys Premiership ,0
4,69,U16-17 Girls ,0
5,34,U12 Girls Premiership ,0
6,29,U12 Boys ,1
7,78,U19 Girls ,1
8,100,Mens O-30 ,1
9,11,U10 Boys ,1
10,47,U14 Boys ,1
11,56,U15 Boys ,1
12,24,U11 Girls ,1
13,42,U13 Girls ,1
14,60,U15 Girls ,1
15,35,U12 Girls UEFA Cup ,1
16,53,U14 Girls UEFA Cup ,1
17,52,U14 Girls Premiership ,1
18,38,U13 Boys ,2
19,110,U16 Boys ,2

Is this possible? I have looked at array_multisort and unless I am reading it wrong, it doesn't look like it would do what I needed.

Thank You
Steve



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to