dalecosp;11026455 wrote:This would be an example of why UNIX timestamps were invented ... you just SORT_NUMERIC them.
Of course, you may not have control of your data 😉
I don't think that's an issue here -- as long as the times are based on a 24-hour clock and all numbers are zero-padded, in which case a normal string compare should work just fine. The primary issue, I believe, is just dealing with the fact that it's a multi-dimension array, so you need to let PHP know which sub-element needs to be compared (which I personally find easier to do with usort() than with array_multi_sort()).
<?php
$theArray = array(
array(
'11:45:00',
'Hull Middle School',
'X',
'S'
),
array(
'09:00:00',
'Hull Middle School',
'S',
'V'
),
array(
'14:30:00',
'Hull Middle School',
'S',
'W'
)
);
echo "<pre>".print_r($theArray,1)."</pre>\n";
usort(
$theArray,
function ($a, $b)
{
return strcmp($a[0], $b[0]);
}
);
echo "<pre>".print_r($theArray,1)."</pre>\n";