How can you sort an array first by one key and then by another key in PHP?

To sort an array first by one key and then by another key in PHP, you can use the `array_multisort()` function. This function allows you to sort multiple arrays or a multi-dimensional array by one or more key values. By specifying the keys you want to sort by and the sorting order for each key, you can achieve the desired sorting behavior.

// Sample array to be sorted
$users = [
    ['name' => 'Alice', 'age' => 30],
    ['name' => 'Bob', 'age' => 25],
    ['name' => 'Charlie', 'age' => 30],
];

// Sort the array first by age in descending order and then by name in ascending order
array_multisort(array_column($users, 'age'), SORT_DESC, array_column($users, 'name'), SORT_ASC, $users);

// Output the sorted array
print_r($users);