Local Hero
11-07-2012, 08:41 AM
I have code that saves images to a directory based on the last 5 digits of the session ID. So I have a list of images 12345-hello.jpg, 12345-goodbye.jpg, 54321-adios.png, etc.
I have a script to display the files, but there are a lot of images to load. If I only want to see the files from "12345", I would like to have the PHP display only those files.
My code to get the images:
<?php $files = glob("uploaded/*.*"); for ($i=0; $i<count($files); $i++) {$num = $files[$i];print $num."<br />";echo '"<a href="'.$num.'"><img width=500 src="'.$num.'" alt="" />'."<br /><br /></a>"; } ?>
I think I have to use PREG_MATCH, but as simple as looking for files is, it was tough for me to get to this point.
Can I get a little bump over the hill so I can search for just a string that I can input?
Thanks!
I have a script to display the files, but there are a lot of images to load. If I only want to see the files from "12345", I would like to have the PHP display only those files.
My code to get the images:
<?php $files = glob("uploaded/*.*"); for ($i=0; $i<count($files); $i++) {$num = $files[$i];print $num."<br />";echo '"<a href="'.$num.'"><img width=500 src="'.$num.'" alt="" />'."<br /><br /></a>"; } ?>
I think I have to use PREG_MATCH, but as simple as looking for files is, it was tough for me to get to this point.
Can I get a little bump over the hill so I can search for just a string that I can input?
Thanks!