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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.