Jump to content

How can I get the index values of an array into a new array?


physaux

Recommended Posts

Here is the kind of array I have, sorted by the 'score':

$players['george'] = 81;

$players['simon'] = 74;

$players['sally'] = 44;

...

 

Now I am in the middle of an array, And I want to print out the 'name' with the score:

foreach($players as $player){

    echo ???NAME???.' -- '.$player.'</br>';

}

 

I want it to output like so

george -- 81

simon -- 74

sally -- 44

 

 

 

So could anyone please tell me how I can get the values? I know there is some function that will make me a new array with the index values, but I can't remember it...

$namearray = mysteryfunction($players);

and $namearray would be

$namearray[0] = "george";

$namearray[1] = "simon";

$namearray[2] = "sally";

...

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.