Jump to content

display images in directory that begin with "refl_"


m_tyhurst2002

Recommended Posts

Hey guys, I have a folder which has images. In this folder there are images that start with "refl_". I want to make sure those are not displayed. This is what I tried and it does not work. I want to show all images that don't start with "refl_". I am new to this as I am sure some can see. Thanks for the help if possible!

 

<?php
			$dir = opendir("img/portfolio/");
			while (false !== ($file = readdir($dir))) 
			{
			$pos = strpos($file, "refl_");
			if ($pos == false)
				{ 
				echo '<img src="img/portfolio/' . $file . '" longdesc="img/portfolio/' . $file . '" /></a>';
				}
			}
		?>

Thanks, glob() was able to do it all kind of. Changed file names for the ones that I want shown to have "www_" at the begining.

 

<?php
                $dir = "img/portfolio/www_*";
                foreach (glob($dir) as $file)
                {
           	 		echo '<img src="' . $file . '" longdesc="' . $file . '" width="800" height="481" />';
                }
            ?> 

 

I am trying to learn... I guess I wouldn't need to closedir() if I didn't opendir() right, since I am using glob()? Thanks

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.