Jump to content

Accessing array keys numerically


ThePsion5

Recommended Posts

Hi again,I have a function that outputs a rather large associative array in a order based on the values in the array. It starts being completely unordered, but i need to arrange it in an order similar to this:

word1 => 40word2 => 37other thing => 20something => 17else => 15
as in, ordered by the array values instead of the associative keys. I know that I can do this using the aSort() function, but this sorts them in reverse order, which means I have to use the array_reverse() function to flip it around the way I want it. I'm trying to find a way to eliminate that costly call to array_reverse(), but in order to do that I need to use a for loop that runs in reverse, like this:
for($i = $count; $i > 0; $i--){$Output .= array[$i] . "\n";}

But i need to access the associative array keys in this for loop. Is there any way to do it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...