What is the best way to sort a two-dimensional array in PHP based on the values in the second dimension?

When sorting a two-dimensional array in PHP based on the values in the second dimension, you can use the `array_multisort()` function along with a custom sorting function that accesses the values in the second dimension. This allows you to sort the array based on the values of a specific key in the inner arrays.

// Sample two-dimensional array
$array = array(
    array('name' => 'John', 'age' => 30),
    array('name' => 'Alice', 'age' => 25),
    array('name' => 'Bob', 'age' => 35)
);

// Custom sorting function based on the 'age' key in the inner arrays
function custom_sort($a, $b) {
    return $a['age'] - $b['age'];
}

// Sort the array based on the 'age' key in the inner arrays
usort($array, 'custom_sort');

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