How can the asort function in PHP help maintain the key-value pairs in an array during sorting operations?
When sorting an array in PHP using functions like `sort()` or `rsort()`, the key-value pairs are not maintained, and the keys are re-indexed numerically. To maintain the key-value pairs during sorting operations, you can use the `asort()` function in PHP. `asort()` sorts an array by values while maintaining the association between keys and values.
$fruits = array("a" => "apple", "b" => "banana", "c" => "cherry");
asort($fruits);
foreach ($fruits as $key => $value) {
echo "$key: $value\n";
}