Jump to content

[SOLVED] Need help


david212

Recommended Posts

$dir = new DirectoryIterator( '/www/test/' );

foreach($dir as $file )

{

  if(!$file->isDot() && !$file->isDir() && preg_match("/.gif$/",$file->getFilename())) {

    echo "FileName: ".$file->getFilename();

    echo "Size: ".number_format(($file->getSize()/1024),2)." Kb";

    }

}

Link to comment
https://forums.phpfreaks.com/topic/146980-solved-need-help/#findComment-771652
Share on other sites

Thanks a lot but i have one question: i wrote this code:

 

<?php

 

 

$myAr = array("1.jpg","2.jpg","3.jpg","4.jpg","5.GIF","6.gif");

 

 

$s=sizeof($myAr);

for($i=0;$i<$s;$i++){

 

if($myAr[$i]=="*.jpg"){

echo("<img src = \"pics/".$myAr[$i]."\" width=\"200\" height = \"200\">");

 

}

 

 

}

 

?>

 

where i made mistake? how can i define file extension in this case using "*.jpg", all that i need to know, how can define file extension usind for loop?

 

Thanx

Link to comment
https://forums.phpfreaks.com/topic/146980-solved-need-help/#findComment-771792
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.