经测试代码如下:
<?PHP
/**
* 显示文件夹下所有图片
*
* @param
* @arrange (512.笔记) jb51.cc
**/
$fileTypes = array('jpg','jpeg','gif','png');
$width = 100;
$height = 100;
$pageTitle = "Pictures";
// *************************************************************
$f = join(',*.',$fileTypes);
$f = '*.'.$f;
$height += 20;
/*** 来自:编程之家 jb51.cc(jb51.cc) ***/
?>
经测试代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<Meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><?PHP echo $pageTitle; ?></title>
<style type="text/css">
<!--
* { margin:0; padding:0; }
h1 { background:#eee; font-weight:normal; padding:3px 5px; font-size:medium; }
ul { margin-top:10px; list-style:none; }
ul li { width:<?PHP echo $width; ?>px; height:<?PHP echo $height; ?>px; float:left; padding:5px; overflow:hidden; margin-bottom:10px; }
ul li span { height:20px; font-size:medium; font-style:italic; }
ul li a img { width:<?PHP echo $width; ?>px; border:dotted 1px #ddd; }
-->
</style>
</head>
<body>
<h1><?PHP echo $pageTitle; ?></h1>
<ul>
<?PHP $loop = 1; foreach (glob("{".$f."}",GLOB_BRACE) as $fileName) { ?>
<li>
<span><?PHP echo $loop; ?></span>
<a href="<?PHP echo $fileName; ?>" target="_blank"><img alt="<?PHP echo $fileName; ?>" src="<?PHP echo $fileName; ?>" /></a>
</li>
<?PHP $loop++; } ?>
</ul>
</body>
</html>
<!-- 来自 编程之家 jb51.cc (jb51.cc)-->