Forum Moderators: open

Message Too Old, No Replies

Regex & Increment

         

kevmeister

9:41 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



Hi guys and gals :)

I need some help with regular expressions.

I need to create a list of URL's where the only thing that changes in each instance is a filename, i.e:

site.com/001.jpg
site.com/002.jpg
..etc

So I thought the easiest thing to do would be to type the first URL and copy and paste it the required number of times, then change the filenames after. Only trouble is I don't know how!

I Googled for things like "Regular Expressions + Increment" and variations on that, but didn't turn up much.

syktek

2:34 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



i think using a looper would be best. in php you could use:

<?php
$i=1;
while($i<=6) {
echo '<img src="images/0' . $i . '.jpg" /><br />';
i++
}
?>

what this code says start with the number 1 and compare it to 6(6 being the number of images you want to display, change accordingly), once you get to 6 stop. then it displays the images as
images/01.jpg
images/02.jpg

so as long as your images were named 01, 02, 03 this would work, if you are trying to display more then 9 images you would need to remove 0 from the single digit named images and out of this code.

hope this helped