What is the difference between sort(), rsort(), and usort() functions in PHP?

The main difference between sort(), rsort(), and usort() functions in PHP is the way they sort arrays. - sort(): This function sorts an array in ascending order. - rsort(): This function sorts an array in descending order. - usort(): This function allows you to define a custom comparison function to sort the array.

// Example of using sort() function
$numbers = array(4, 2, 8, 6);
sort($numbers);
print_r($numbers);

// Example of using rsort() function
$numbers = array(4, 2, 8, 6);
rsort($numbers);
print_r($numbers);

// Example of using usort() function
function custom_sort($a, $b) {
    return $a - $b;
}

$numbers = array(4, 2, 8, 6);
usort($numbers, "custom_sort");
print_r($numbers);