PHPでレコードを昇順、降順にソートして出力
//昇順
foreach($files as $file_num => $file) {
if(is_file($directory.$file)){
//$file = iconv(“shift-jis","UTF-8″,$file);
$date = substr($file,0,9);
echo '<li class="world-cup-'.$date.'">’;
echo '<a href="'.$directory.$file.'" rel="worldcup" title="ワールドカップ’.$date.'">’;
echo '<img src="'.$directory.$file.'" alt="">’;
echo '</a>’;
echo '</li>’;
}
}
// 降順
foreach(array_reverse($files) as $file_num => $file) {
if(is_file($directory.$file)){
//$file = iconv(“shift-jis","UTF-8″,$file);
$date = substr($file,0,9);
echo '<li class="world-cup-'.$date.'">’;
echo '<a href="'.$directory.$file.'" rel="worldcup" title="ワールドカップ’.$date.'">’;
echo '<img src="'.$directory.$file.'" alt="">’;
echo '</a>’;
echo '</li>’;
}
}