<?php
/* "get list of images based on width and height" */
$dirpath = 'imgdirname'; // Name of folder(directory) containing the images files
function getimg($w,$h,$dirpath)
{
$filesimg= array();
$dh = opendir($dirpath);
while (false !== ($filename = readdir($dh)))
{
if(!is_dir($filename))
{
$imginfo = getimagesize($dirpath.'/'.$filename);
if($imginfo[0] == $w || $imginfo[0] == $h ){
$filesimg[] = $filename;
}
}
}
sort($filesimg);
return $filesimg;
}
$imgdata = getimg(100,100,$dirpath);
echo "<pre>";print_r($imgdata); exit;
/* get list of html files from a directory*/
$dirpath = 'htmlfiledirc'; // Name of folder(directory) containing all the html files
function getHtmlfileList($dirpath,$fileExt)
{
$fileshtml= array();
$dh = opendir($dirpath);
while (false !== ($filename = readdir($dh)))
{
$files[] = $filename;
if(!is_dir($filename) && strstr($filename,$fileExt)){
$fileshtml[] = $filename;
}
}
return $fileshtml;
}
$fileExt = '.html';
$filesdata = getHtmlfileList($dirpath,$fileExt);
echo "<pre>";print_r($imgdata); exit;
?>
/* "get list of images based on width and height" */
$dirpath = 'imgdirname'; // Name of folder(directory) containing the images files
function getimg($w,$h,$dirpath)
{
$filesimg= array();
$dh = opendir($dirpath);
while (false !== ($filename = readdir($dh)))
{
if(!is_dir($filename))
{
$imginfo = getimagesize($dirpath.'/'.$filename);
if($imginfo[0] == $w || $imginfo[0] == $h ){
$filesimg[] = $filename;
}
}
}
sort($filesimg);
return $filesimg;
}
$imgdata = getimg(100,100,$dirpath);
echo "<pre>";print_r($imgdata); exit;
/* get list of html files from a directory*/
$dirpath = 'htmlfiledirc'; // Name of folder(directory) containing all the html files
function getHtmlfileList($dirpath,$fileExt)
{
$fileshtml= array();
$dh = opendir($dirpath);
while (false !== ($filename = readdir($dh)))
{
$files[] = $filename;
if(!is_dir($filename) && strstr($filename,$fileExt)){
$fileshtml[] = $filename;
}
}
return $fileshtml;
}
$fileExt = '.html';
$filesdata = getHtmlfileList($dirpath,$fileExt);
echo "<pre>";print_r($imgdata); exit;
?>
No comments:
Post a Comment