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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.