How can a two-dimensional array be sorted in PHP based on a specific column?

To sort a two-dimensional array in PHP based on a specific column, you can use the `array_multisort()` function along with a custom function to extract the column values for sorting. The custom function will extract the values from the specified column and pass them to `array_multisort()` along with the original array.

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

// Function to extract column values for sorting
function getColumn($array, $column) {
    $col = array();
    foreach ($array as $key => $row) {
        $col[$key] = $row[$column];
    }
    return $col;
}

// Sort the array based on the 'age' column
array_multisort(getColumn($array, 'age'), SORT_ASC, $array);

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