I have about 1300 files following this naming structure
Still + "artist name" + "image index" + "a constant tag" + ".cfi"
examples:
StillAAndrewGonzalez000(http://www.caiaffa.com).cfi
StillLopesGarcia013(http://www.caiaffa.com).cfi
I have to read the directory files, and assign and array wich will hold the artists name and the numer of images that
the artist have in the directory. this is determined by the highest number found in the image index part of the filename
I am able to read the directory, and make and array with the artists names, but i need to assign the number of images value
in the same reading process as I am using to split the artists name apart.
-----------------------
-----------------------
Hello
I am creating a web-based images gallery slideshow wich needs a lot of unic features associated to it.
The script must be able to do a few things:
-Capture the image files from the web directory in the array (done)
-Recognize a certain string in the file name, wich will be used to associate files to its artists:
-all images files follow the same naming structure, wich is:
Still + "artist name" + "image index" + "a constant tag" + ".cfi"
the cfi extension is just any image (jpg,bmp,jpeg) renamed to cfi
examples:
StillAAndrewGonzalez000(http://www.caiaffa.com).cfi
StillLopesGarcia013(http://www.caiaffa.com).cfi
-This slideshow php script should pick a random artist from the entire list of artists, then select n images
from the selected artist for playing. When the playback is done, it repicks another artists and images.
-It must have conditions to avoid repeating artists that were already played, untill all artists have been played.
Also, avoiding to select the same instance of images when selecting the n images from the current artist.
I have the basic slideshow code running at
http://www.caiaffa.com/Showcase/testeFADE8.php
So far, all it does is agregate the image files in an array and using it to play files randomly.
---
I have coded the entire solution in flash-actionscript,
http://www.caiaffa.com/Showcase/Galeria ... %20net.swf
wich is much more my game, but unfourtunately the project
now demands that I code it entirely in php/js/html, all of wich Im very novice.
the actionscript solution used a manually created txt list of all the artists and how many images each of them have in the
directory, now I should work towards coding it so that it will generate this listing dinamically.
Any help is appreciated, even if only to direct me to some usefull tutorials.
It is the string manipulation part wich im battling with. I should be able to make all the array assigning in one reading of the directory files, but its been hard to figure out the correct way.
From my images of directory i need to:
-read each file name
-take out the "Still" string AND (http://www.caiaffa.com).cfi AND the three numbers before the caiaffa url tag
-assign the remaining as the artist name
-read the image index (the three numbers) and, untill the artist name doesnt match anymore, sum it all up and assign the
value as the total number of images for that artist.
so, for StillAAndrewGonzalez000(http://www.caiaffa.com).cfi
it would take the artist name (AAndrewGonzalez), put it in the artists array
then for every new file with the same artists name, add up to an image counter
after reading all files is done, assign the image counter numbers to their respective artists, in a new array or in a possible
multidimensional array storing Artist and Number of images.
the way im working right now, im trying to match "000" to the filename string, and if theres a match, split and store the artist name.
this is ok to hold the artist name, but if i want to assign how many images any artist have, ill have to re-read the entire filenames
array.
what i got so far (wich will end up wastefull)
Code: Select all
<?
function returnimages($dirname="./Galeria/") {
$pattern="(\.jpg$)|(\.cfi$)|(\.jpeg$)|(\.gif$)";
$defaultdir="http://www.caiaffa.com/Showcase/Galeria/";
$files = array();
$curimage=0;
$fadeimages= array();
$artists= array();
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
array_push ($fadeimages, $defaultdir . $file);
print_r($fadeimages[$curimage]);
$curimage++;
echo '<br>';
$pos = strpos($file, "000");
if ($pos === false) {
} else {
$chunks = split ("000", $file, 5);
$finalchunk = split ("Still", $chunks[0], 5);
array_push($artists ,$finalchunk[1]);
print_r($finalchunk[1]);
echo '<br>';
}
}
}
closedir($handle);
}
echo '<br>';
echo '<br>';
echo '<br>';
print_r($artists);
return($files);
}
returnimages();
?>