I want to create something very simple but, having not coded anything in a few years (limited then anyway), I'm having trouble wrapping my head around it. What I'd like is to have is a single index.php file and just upload image files (jpg and gif) into the same folder in this format:
1-06052007-000000.jpg
2-06062007-ffffff.jpg
3-06082007-ff0000.gif
Then I'd like index.php to include:
...
background: #ff0000;
...
<a href="?page=2"><img src="3-06082007-ff0000.gif" width="width" height="height" alt="June 8, 2007 - Page 3" /></a>
So... It would be something to the effect of:
opendir > only image files (jpg, gif, png) > array (reverse?)> explode highest number([0] if reverse I suppose) or "?page"> break apart "-" to array > link to the one before current, unless there isn't one then redirect to highest number
I have a lot of the elements and I've been looking over tons of functions, but I'm having trouble bringing it all together with my lack of experience.
Does this make sense?
Somewhat Daily Image Script
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
I'm gettin it figured out a bit... For simplicity I changed my image format to: number . date . bg . format (ie 1.060507.000000.jpg)
How do I take the arrays spit out and cherry pick the one with the highest value in $info[0] and then get the subsequent info from that particular array?
How do I take the arrays spit out and cherry pick the one with the highest value in $info[0] and then get the subsequent info from that particular array?
Code: Select all
<?php
$directory = ".";
$open = opendir($directory);
while (false !== ($file = readdir($open))) {
if (preg_match("/\.(jpeg|jpg|gif|png)$/i", $file)) {
$info = explode(".", $file);
$page = $info[0];
$date = $info[1];
$bg = $info[2];
}
}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA