How does the usort() function in PHP compare to array_multisort() when sorting multidimensional arrays?

When sorting multidimensional arrays in PHP, the usort() function is used to sort the array based on a user-defined comparison function. This allows for custom sorting logic to be applied to the array elements. On the other hand, array_multisort() is a built-in function that can sort multiple arrays or multidimensional arrays based on one or more sort order arguments.

// Example of using usort() to sort a multidimensional array
$users = [
    ['name' => 'John', 'age' => 30],
    ['name' => 'Jane', 'age' => 25],
    ['name' => 'Alice', 'age' => 35]
];

usort($users, function($a, $b) {
    return $a['age'] - $b['age'];
});

print_r($users);