any php gurus?
#1
any php gurus?
i want a script to enumerate through the files in a sub directory
I know it'll be 10 lines of code, so
sorry, i'm a little dense on this, i'm an asp boy <embarrassed>
help appreciated
CD
I know it'll be 10 lines of code, so
sorry, i'm a little dense on this, i'm an asp boy <embarrassed>
help appreciated
CD
#2
Scooby Regular
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes
on
0 Posts
In it most basic form this will show you all the images in your current folder:
<html>
<body>
<?php
$d = dir(".");
$count=1;
while (false !== ($entry = $d->read())) {
$lowname=strtolower($entry);
$pos1 = strpos($lowname, '.jpg');$pos2 = strpos($lowname, '.gif');$pos3 = strpos($lowname, '.png');$pos4 = strpos($lowname, '.bmp');
if ($pos1 == true || $pos2 == true || $pos3 == true|| $pos4 == true) {
echo '<p><img src="'.$entry.'"/></p>';
}
}
$d->close();?>
</body>
</html>
<html>
<body>
<?php
$d = dir(".");
$count=1;
while (false !== ($entry = $d->read())) {
$lowname=strtolower($entry);
$pos1 = strpos($lowname, '.jpg');$pos2 = strpos($lowname, '.gif');$pos3 = strpos($lowname, '.png');$pos4 = strpos($lowname, '.bmp');
if ($pos1 == true || $pos2 == true || $pos3 == true|| $pos4 == true) {
echo '<p><img src="'.$entry.'"/></p>';
}
}
$d->close();?>
</body>
</html>
#5
ok, can i have some sample code then?
how do i do a querystring, eg; www.page.com?variable=image_name
how do i do a querystring, eg; www.page.com?variable=image_name
#6
#7
Scooby Regular
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes
on
0 Posts
yeah, that code does suck but Chef didnt say exactly what he wanted to do with each file, I just used that as an example ... but I never did bother to get the hang of regular expressions though ... lol