How to flip the array?

PHP guru please tell me there is a shopping cart in php + AJAX, writing items in the session, then deduce via AJAX cycle:
foreach ($_SESSION['basket'] as $key => $value) {
Everything works. Now I want to display the array "backwards" use:
foreach (array_reverse($_SESSION['basket']) as $key => $value) {

The data cycle is displayed "backwards", the same everything is OK. Now the challenge is to get the key, if you just use the $key, it will print 1,2,3,4,5 in order. How to "flip" the $key from large to smaller?

I hope you understand ^_^
July 2nd 19 at 14:10
1 answer
July 2nd 19 at 14:12
Solution
The list of parameters
array: Input array.
preserve_keys: If set to TRUE, the keys will be saved. Non-numeric keys are not affected by this option and always persist.
php.net/manual/ru/function.array-reverse.php
Thank you, even I never additional attributes in functions not watched :) - Vernon.Schu commented on July 2nd 19 at 14:15

Find more questions by tags PHPArrays