What PHP function can be used to sort an associative array by its values?

To sort an associative array by its values in PHP, you can use the `asort()` function. This function will sort the array in ascending order based on its values while maintaining the key-value associations. This can be useful when you need to organize the data in the array based on certain criteria stored in the values.

$associativeArray = array("key3" => 30, "key1" => 10, "key2" => 20);

asort($associativeArray);

foreach ($associativeArray as $key => $value) {
    echo $key . " => " . $value . "\n";
}