I have a folder with pics and I need to use scandir() to show all images in a html file. But scandir returns, for example, "image.jpg1". Why? How can I do that withouth problems?

Recommended Answers

Try:

$f=scandir('/Images/');
foreach($f as $p)
{
 echo '<img src="/Images/'.$p.'" />';
}
Jump to Post

All 3 Replies

Try:

$f=scandir('/Images/');
foreach($f as $p)
{
 echo '<img src="/Images/'.$p.'" />';
}

try the improve of hielo.

$f=scandir('/Images/');
foreach($f as $p)
{
  if($p=="." || $p=="."){
}
else{
 echo '<img src="/Images/'.$p.'" />';
}}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.