What function can be used to sort an array based on a specific key value in PHP?
To sort an array based on a specific key value in PHP, you can use the `array_multisort()` function. This function can sort multiple arrays or a multi-dimensional array based on the values of one or more keys. By specifying the key you want to sort by, you can rearrange the elements of the array accordingly.
// Sample array to be sorted based on the 'key' key
$array = array(
array('key' => 5, 'value' => 'apple'),
array('key' => 3, 'value' => 'banana'),
array('key' => 8, 'value' => 'orange')
);
// Sort the array based on the 'key' key in ascending order
array_multisort(array_column($array, 'key'), SORT_ASC, $array);
// Output the sorted array
print_r($array);