views:

46

answers:

3

When I use the sort function in php it deletes all of the keys. What's an alternative method?

+6  A: 

I think the asort function is what you're looking for.

Tim Cooper
Thank you, seems like a bit of an after thought from the PHP developers.
Ben Shelock
+4  A: 

You want to use asort instead of sort which keeps your key associations intact:

http://php.net/asort

hurikhan77
+3  A: 

asort — Sort an array and maintain index association. I guess that is what you're searching for.

AndiDog