首頁 >後端開發 >php教程 >php foreach正序倒序輸出範例

php foreach正序倒序輸出範例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-07-25 09:12:001774瀏覽

php foreach正序倒序输出

例子:

  1. // 正序
  2. foreach($files as $file_num => $file) {
  3. if(is_file($directory.$file)){
  4. //$file = iconv("gb2312","UTF-8",$file); //或者 iconv("gb2312","UTF-8",$value);
  5. $date = substr($file,0,9);
  6. echo '
  7. ';
  8. echo '';
  9. echo '';
  10. echo '';
  11. echo '
  12. ';
  13. }
  14. }
  15. // 倒序
  16. foreach(array_reverse($files) as $file_num => $file) {
  17. if(is_file($directory.$file)){
  18. //$file = iconv("gb2312","UTF-8",$file); //或者 iconv("gb2312","UTF-8",$value);
  19. $date = substr($file,0,9);
  20. echo '
  21. ';
  22. echo '';
  23. echo '';
  24. echo '';
  25. echo '
  26. ';
  27. }
  28. }
复制代码


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn