Jump to content

[SOLVED] Array Keys


Doyley

Recommended Posts

Hi all,

 

I'm having a problem with array keys.  Here is my code..

 


$selectsql="select distinct playerid from results where seasonid='$season'";
$selectnew=mysql_query($selectsql) or die(mysql_error());

while($sel=mysql_fetch_array($selectnew)){

$select2sql="select points from results where playerid='$sel[0]' and seasonid='$season'";
$select2new=mysql_query($select2sql) or die(mysql_error());

while($sel2=mysql_fetch_array($select2new)){

$pl="AA".$sel[0];

$prev=$arr[$pl];
$new=$prev+$sel2[0];

$arr[$pl]=$new;


}
}

rsort($arr);

echo "<pre>\n";
print_r($arr);

echo "</pre>\n";

 

The above outputs the following..

 


Array
(
    [0] => 50
    [1] => 46
    [2] => 44
    [3] => 34
)

 

I need it to output

 


Array
(
    [AA1] => 50
    [AA2] => 46
    [AA3] => 44
    [AA4] => 34
)

 

If I remove rsort() it works but I need that in there.  Can anybody help?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/99345-solved-array-keys/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.