How can usort() be utilized in PHP to sort an array based on a specific key value?

To sort an array based on a specific key value in PHP, you can use the `usort()` function along with a custom comparison function. This allows you to define the criteria for sorting the array elements based on a specific key value.

// Sample array to be sorted based on 'key'
$array = [
    ['key' => 3, 'value' => 'C'],
    ['key' => 1, 'value' => 'A'],
    ['key' => 2, 'value' => 'B'],
];

// Custom comparison function to sort based on 'key'
usort($array, function($a, $b) {
    return $a['key'] - $b['key'];
});

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