to start with the routine is like the title.
Upload file to the server (pictures) it will use the $timestamp = time(); to create a folder to hold all the pictures and using the same $timestamp to create a xml file.
$xml_file = $timestamp.".xml"
the structure of the xml file is like this:
<album title="$title">
<picture>
<name>$name</name>
<size>$size</size>
<caption>$caption</caption>
<picture>
<picture>
<name>$name</name>
<size>$size</size>
<caption>$caption</caption>
<picture>
......//and more pictures
</album>
all this file will store in "./image/gallery/info" so I dont have to look every where.
This part I have done it beautifully :-)
Now part 2:
using PHP to search the top image folder to find out how many albums there
$folder = "./image/gallery/info";
$handle = dir($folder)
$i=0;
while ($file = $handle->read)
{
if (($file!=".") && ($file!=".."))
{
$xml_file[$i]=$file;
}
$i++;
}
this part done beautifully again.
then using PHP SAX to read thourgh the files
I save you with the code because its really common way just parsing the whole lot etc etc.
And again I have done it.
trouble begins.
I try so many different way to pack the data into one single array.
$main_album_info = array();
this array will contain
1. the title name;
2. all the pictures info;
so one more array $picture_info;
I end up with a six level nest array.
like this
$main_album_info
--> $album_info
----> $album_title
------> $picture_name
--------> $picture_size
---------->$picture_caption
really messy!!!
I already using the time stamp to save me one more nest (I almost can claim that reward from wrox by doing a 10 nest array chains ;-)
Now the question is how can I simpify this whole thing because one could pack and unpack the whole thing but it's really messy and the code are not exactly easy to read and maintain.
cos the next step is I will using the unpack info to build a javascript slideshow.If I can't find a better and simple way to pack and unpack the info in and out from xml files will be ... really sucks.
Any idea guys???
I have think about using database instead but the trouble is I am building two different client side one is DHTML and the other one is Flash that's why I use XML to store the info in the first place. And by doing this I can start learning how to parse xml file using PHP because the next thing I will do is using xml to inteact with other languages (python, java, perl etc)
Thanks in advance.