我目前正在尝试制作一个脚本,在目录和子目录中找到带有*.jpg/*.png扩展名的图像.
如果找到某些带有这些扩展名的图片,则将其保存到包含路径,名称,大小,高度和宽度的数组中.
到目前为止,我有这段代码,它将找到所有文件,但我不知道如何只获取jpg/png图像.
class ImageCheck {
public static function getDirectory( $path = '.', $level = 0 ){
$ignore = array( 'cgi-bin', '.', '..' );
// Directories to ignore when listing output.
$dh = @opendir( $path );
// Open the directory to the handle $dh
while( false !== ( $file = readdir( $dh ) ) ){
// Loop through the directory
if( !in_array( $file, $ignore ) ){
// Check that this file is not to be ignored
$spaces = str_repeat( ' ', …Run Code Online (Sandbox Code Playgroud)