How can you sort a multidimensional array in PHP based on a specific field?
When sorting a multidimensional array in PHP based on a specific field, you can use the `array_multisort()` function along with a custom sorting function. This function allows you to specify the field you want to sort the array by and the sorting order (ascending or descending).
// Sample multidimensional array
$users = [
['name' => 'John', 'age' => 25],
['name' => 'Alice', 'age' => 30],
['name' => 'Bob', 'age' => 20]
];
// Sort the array based on the 'age' field in ascending order
array_multisort(array_column($users, 'age'), SORT_ASC, $users);
// Print the sorted array
print_r($users);