How can custom sorting be implemented in PHP for multidimensional arrays?

When working with multidimensional arrays in PHP, custom sorting can be implemented by using the `usort()` function along with a custom comparison function. This function will define the logic for how the elements should be sorted based on specific criteria within the multidimensional array.

// Sample multidimensional array
$users = [
    ['name' => 'John', 'age' => 30],
    ['name' => 'Alice', 'age' => 25],
    ['name' => 'Bob', 'age' => 35]
];

// Custom sorting function based on age
usort($users, function($a, $b) {
    return $a['age'] <=> $b['age'];
});

// Output sorted array
print_r($users);