Thumbnail Gallery

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Thumbnail Gallery

Post by trent2800 »

I'm trying to set up a gallery of previous products. I am trying to find out how I would search a directory for files and then display them. Does anyone know a function that would do this?

e.g. In path /www/images/sold/ the script would search the dir for all the images and thumbnails then put in an img tag.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

glob() maybe?
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Post by trent2800 »

Yeah, that works, thanks.

Now, how bout this one. My filenames are something like th_123.jpg. How would I get the 123 out of that? I tried substr but it breaks if the id is less or more than 3 chars.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Post by trent2800 »

that elipsis reeks of sarcasam... I like it.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

trent2800 wrote:that elipsis reeks of sarcasam... I like it.
don't know what "elipsis reeks" is but anyhow :)

Of course it depend on your filenames.

Code: Select all

//e.g with th_123.jpg 

preg_match('#^.*?_(\d+)\.(jpg|png)$#','th_123.jpg',$match);
var_export($match);

//Output
array (
  0 => 'th_123.jpg',
  1 => '123',
  2 => 'jpg',
)
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Post by trent2800 »

Awesome, it works, thanks a lot.


Elipsis: ...

Reeks: to smell to a great degree

So, his '...' was stinky with sarcasam. Thats what I ment.
Post Reply