How can I list all the files (images) inside a directory that start with 1_...
1_ is actually a user id, I've made it so each time a user uploads a image it adds #_ to the beginning of the image and stripes any other underscores.
PHP Code:
<?
ob_start();
include("config.php");
$path = "";
$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle))
{
if($file!="." && $file!="..")
echo "<a href='view.php?image=$file'><img src='thumbs/$file'></a>";
}
closedir($dir_handle);
?>
This is what I'm using at the moment... but I would like it so that it would only show files with 1_ or whatever.
PHP Code:
substr($_GET['image'], 0, strpos($_GET['image'], '_'));
I'm using this on other pages to get the number in fornt of the image. Thanks to sitepoint.
|