// 正序 foreach($files as $file_num => $file) { if(is_file($directory.$file)){ //$file = iconv("gb2312","UTF-8",$file); //或者 iconv("gb2312","UTF-8",$value); $date = substr($file,0,9); echo '<li>'; echo '<a href="'https://www.jb51.net/article/.$directory.$file.'" title="巴西世界杯赛事'.$date.'">'; echo '<img src="'https://www.jb51.net/article/.$directory.$file.'" alt="">'; echo '</a>'; echo '</li>'; } } // 倒序 foreach(array_reverse($files) as $file_num => $file) { if(is_file($directory.$file)){ //$file = iconv("gb2312","UTF-8",$file); //或者 iconv("gb2312","UTF-8",$value); $date = substr($file,0,9); echo '<li>'; echo '<a href="'https://www.jb51.net/article/.$directory.$file.'" title="巴西世界杯赛事'.$date.'">'; echo '<img src="'https://www.jb51.net/article/.$directory.$file.'" alt="">'; echo '</a>'; echo '</li>'; } }
php foreach正序倒序输出示例代码
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/e71b588e84487691723d13323b138eda.html