How can the function array_multisort() be effectively used to sort a multidimensional array in PHP?

To sort a multidimensional array in PHP, you can use the array_multisort() function. This function can sort multiple arrays or a multidimensional array based on one or more keys. By specifying the sorting order and type, you can effectively sort the multidimensional array in PHP.

// Sample multidimensional array
$users = array(
    array('id' => 1, 'name' => 'Alice', 'age' => 30),
    array('id' => 2, 'name' => 'Bob', 'age' => 25),
    array('id' => 3, 'name' => 'Charlie', 'age' => 35)
);

// Sort the array by 'age' in ascending order
array_multisort(array_column($users, 'age'), SORT_ASC, $users);

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