How can the content of an array be sorted in PHP to display data in a specific order, such as by time?

To sort the content of an array in PHP by time, you can use the `usort()` function along with a custom comparison function that compares the time values. This will allow you to display the data in the desired time-based order.

// Sample array with time values
$times = ['10:30', '08:45', '12:15', '09:00'];

// Custom comparison function to sort by time
function sortByTime($a, $b) {
    return strtotime($a) - strtotime($b);
}

// Sort the array by time
usort($times, 'sortByTime');

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