How can I reverse sort an array keeping the correlation between the index and value?
<?php
$myworld = array("a"=>"everything","b"=>"nothing","c"=>"is");
arsort($myworld);
print_r($myworld);
?>
Which prints this:
Array
(
[b] => nothing
[c] => is
[a] => everything
)
Comment on this Question and Answer >>>
ASK A QUESTION
More arrays PHP Questions
Hi. i have a music samples website. in one table, id like a different sample to appear every time the page is refreshed. how do i acheve this? how can i alterate and retrieve these bloody mp3's? surely i can use a PHP script? thankyouHow do I find if a value is already in an array or not?
How can I easily view all members of an array?
How can I mix up the order of values in an array?
How do I change: function wordlimit($string, $length = 50, $ellipsis = "...") { $words = explode(' ', strip_tags($string)); if (count($words) > $length) return implode(' ', array_slice($words, 0, $length)) . $ellipsis; else
