Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello,

The title explains it pretty much. I've a directory with images stored in it. I use the PHP glob() function. Here'e the code:
PHP
$dir = '../images/';
 
foreach(glob($dir. "[". $_GET['ID']. "]". *. '.jpg') as $file) {
    print $file . "\n";
}


I want to be ale to list all the files that begin with a specific character, 2 as example. But, I've to keep it dynamic. I mean I've to keep the $_GET['ID']. And still I want to list all the files that begin with this ID.

How do I do that? Please, rather than referring some to some indirect tutorials, please help me directly.

Appreciated!
Thanks!
Posted

1 solution

This worked :

PHP
$dir = '../images/';

$id = $_GET['ID'];

foreach(glob($dir. "*". $id. "*.jpg") as $file) {
    print $file . "\n";
}


The main line was :
PHP
$dir. "*". $id. "*.jpg"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900