note 112256 deleted from function.array-reverse by aharvey
| From: | aharvey@php.net | Date: | Fri, 24 May 2013 18:11:18 +0000 |
| Subject: | note 112256 deleted from function.array-reverse by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-194941@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
This function doesn't matter what type the keys and values are. It easily reverses the array.
<?php
function reverseArray($arr) {
$keys = array_keys($arr);
$values = array_values($arr);
for ($i = count($keys)-1; $i >= 0; $i--) {
$r_arr[$keys[$i]] = $values[$i];
}
return $r_arr;
}
?>