<?php
$imgdir = 'img/';
$allowed_types = array('png','jpg','jpeg','gif'); //Allowed types of files
$dimg = opendir($imgdir);//Open directory
while($imgfile = readdir($dimg))
{
//please explain this part!!
if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) OR
in_array(strtolower(substr($imgfile,-4)),$allowed_types) )
{$a_img[] = $imgfile;}
}
$totimg = count($a_img);
for($x=0; $x < $totimg; $x++){echo "<li><img src='" . $imgdir . $a_img[$x] . "'/></li>"
;}?>
我明白,这就像婴儿步,但我的问题是:我阅读了 php 手册,但我真的不明白为什么 substr 部分是这样的!请帮忙!谢谢!