php array_reverse keep keys
snippet in php

php array_reverse keep keys

user4967


<?php
$input  = array("php", 4.0, array("green", "red"));
$reversed = array_reverse($input);
$preserved = array_reverse($input, true);

print_r($input);
print_r($reversed);
print_r($preserved);
?>

php loop backwards through array

user7084

$array = array_reverse($array);
foreach($array as $currentElement) {}

php loop backwards through array

user1240

for($i = count($array) - 1; $i >= 0; $i--){

}