The `arsort()` function in PHP is used to sort an associative array in descending order while maintaining the index association.
Syntax
arsort(array &$array, int $flags = SORT_REGULAR): bool
Example
<?php $marks = [ "John" => 85, "Alice" => 92, "Bob" => 78, "David" => 88 ]; arsort($marks); // Sort in descending order while maintaining keys foreach ($marks as $name => $score) { echo "$name: $score\n"; } ?>
Output
Alice: 92 David: 88 John: 85 Bob: 78