Use sorting while still holding keys

When I use the sort function in php, it removes all keys. What is an alternative method?

+3
source share
3 answers

I think the asort function is what you are looking for.

+6
source

You want to use asortinstead sort, which keeps your key associations unchanged:

http://php.net/asort

+5
source

asort - sort an array and maintain index association . This is probably what you are looking for.

+3
source

Source: https://habr.com/ru/post/1732258/


All Articles