Since it's the last field in each line, we can use preg_split() again, and pop off the last element of the resulting array:
<?php
// test data:
$text = array(
'-rw-r--r-- 1 username-wm cust 7999808 Jun 3 12:30 file1.mp3',
'-rw-r--r-- 1 username-wm cust 57347392 May 25 19:28 file3.mp3',
'-rw-r--r-- 1 username-wm cust 6671728 Jun 3 13:09 file2.mp3'
);
// callback sort function:
function mySort($a, $b)
{
$filetime = array();
$values = array($a, $b);
foreach($values as $ix => $val)
{
$parts = preg_split('/\s+/', $val);
$mon = $parts[5];
$day = $parts[6];
$time = $parts[7];
if(strpos($time, ':') === FALSE)
{
$year = $time;
$time = '00:00';
}
else
{
$year = date('Y');
}
$filetime[$ix] = strtotime("$mon $day, $year $time");
}
return($filetime[1] - $filetime[0]);
}
// sort by file date-time, descending:
usort($text, 'mySort');
// output sorted files:
echo "<ul>\n";
foreach($text as $file)
{
printf("<li>%s</li>\n", array_pop(preg_split('/\s+/', $file)));
}
echo "</ul>\n";
// debug data to validate we got the right sort order:
printf("<pre>%s</pre>", print_r($text, 1));