Array oh yay
Posted: Wed Jun 16, 2004 8:31 pm
For the purpose of letting everyone get what i'm trying to say i'm going to post my entire lines of script.
Now All I want to do is move forward and backward in the array. next() and prev() work i'm sure, but I don't know how to go about making a loop or using the functions in a link that would work for the task i'm trying to pull off. I'd like to keep the array on the same page since I plan on have a lot of images.
Code: Select all
$url = "http://www.harkeyahh.com/gallery/images/" ;
$dirname = "images/";
$dir = opendir($dirname);
while(false !=($file = readdir($dir) ) )
{if ( ("$file" != ".") AND ("$file" != "..") )
{
$harkeyfile[] = $file;
$file_list .="<li>$file</li>";
}
}
closedir($dir);
//Files in images are now in an array
sort($harkeyfile);
$mode = current($harkeyfile); // $mode = 0
list($width, $height, $type, $attr) = getimagesize("$url$mode");
echo"<img src="$url$mode" $attr />";
while( list( $element ) = each( $harkeyfile ) )
echo "<a href="$PHP_SELF?">$element<br /></a>";
$mode = next($harkeyfile); // $mode = 'bike';
list($width, $height, $type, $atrib) = getimagesize("$url$harkeyfile");
echo"<img src="$url$harkeyfile" $atrib />";
echo $mode . "\n";
echo "<a href="$PHP_SELF?$mode"> Next maybe?</a>";
$result = count($harkeyfile);
echo "Currently there are: $result images in the gallery";
?>