How can a two-dimensional array be sorted in PHP based on a specific value while maintaining the original key associations?

To sort a two-dimensional array in PHP based on a specific value while maintaining the original key associations, you can use the `uasort()` function along with a custom comparison function. This function will compare the specific value of each sub-array and reorder them accordingly without changing the keys.

<?php
// Sample two-dimensional array
$array = [
    'key1' => ['value' => 5],
    'key2' => ['value' => 3],
    'key3' => ['value' => 8],
];

// Custom comparison function based on the 'value' key
function customSort($a, $b) {
    return $a['value'] <=> $b['value'];
}

// Sort the array based on the 'value' key while maintaining keys
uasort($array, 'customSort');

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