tags:

views:

83

answers:

3
Array (
    [id] => 3
    [user_id] => 1
    [clan_id] => 1
    [date] => 2009-09-24 09:02:05
    [skill1rank] => 1
    [skill1lvl] => 2376
    [skill1xp] => 1804229942
    [skill2rank] => 53
    [skill2lvl] => 99
    [skill2xp] => 120510105
    [skill3rank] => 5526
    [skill3lvl] => 99
    [skill3xp] => 21581237
    [skill4rank] => 622
    ...
    [skill21xp] => 38458116
    [skill22rank] => 184
    [skill22lvl] => 99
    [skill22xp] => 22217059
    [skill23rank] => 5267
    [skill23lvl] => 99
    [skill23xp] => 13396733
    [skill24rank] => 101
    [skill24lvl] => 99
    [skill24xp] => 15724235
    [skill25rank] => 903
    [skill25lvl] => 99
    [skill25xp] => 13373505
)

I want to rename to the keys to $array[0], $array[1], etc.

How would I go about that?


Thanks, Silentghost. Worked nicely. :)

+7  A: 

array_values

SilentGhost
A: 

Use array_values:

array_values( [id] => 3 [user_id] => 1 [clan_id] => 1 [date] => 2009-09-24 09:02:05    
[skill1rank] => 1 [skill1lvl] => 2376 [skill1xp] => 1804229942 [skill2rank] => 53 
[skill2lvl] => 99 [skill2xp] => 120510105 [skill3rank] => 5526 [skill3lvl] => 99 
[skill3xp] => 21581237 [skill4rank] => 622 ... [skill21xp] => 38458116 [skill22rank] => 
184 [skill22lvl] => 99 [skill22xp] => 22217059 [skill23rank] => 5267 [skill23lvl] => 99 
[skill23xp] => 13396733 [skill24rank] => 101 [skill24lvl] => 99 [skill24xp] => 15724235 
[skill25rank] => 903 [skill25lvl] => 99 [skill25xp] => 13373505 );
andreas
A: 

Here's my solution:

$array = array(
    "id" => 3,
    "user_id" => 1,
    "clan_id" => 1,
    "date" => "2009-09-24 09:02:05",
    "skill1rank" => 1,
    "skill1lvl" => 2376,
    "skill1xp" => 1804229942,
    "skill2rank" => 53,
    "skill2lvl" => 99,
    "skill2xp" => 120510105,
    "skill3rank" => 5526,
    "skill3lvl" => 99,
    "skill3xp" => 21581237,
    "skill4rank" => 622,
);

$newArray = array();
foreach($array as $key => $value) {
    $newArray[] = $value;
}
Cadu de Castro Alves