Friday 31 May 2013

"Get list of images based on width and height AND get list of files from a directory based on files extenstion"

<?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;
?>

No comments:

Post a Comment

List OF BANK PAN Numbers

List OF BANK PAN Numbers Bank/Home Loan Providers PAN Number Allahabad Bank AACCA8464F Andhra Bank AABCA7375C Axis Bank...