Forum Moderators: coopster

Message Too Old, No Replies

Flat File Photo Gallery

Best Way?

         

Kings on steeds

6:59 pm on Sep 4, 2006 (gmt 0)

10+ Year Member



Hello, i simply want a little bit of help with my flat file photo gallery, this is how i want it to work, admin uploads photo, giving it a filename and a comment, i would like these to var's to be stored in a .pmf(photo managment file) file, now all this i can do, what i am having trouble with is how to sperate my variabels, what i want?

to load my .pmf file each line is a photo and a comment,

./imgs/image1.jpg /*/*/ Me Sking - Oh What Fun
./imgs/image2.jpg /*/*/ The Alps In All There Glory

so how do i do a foreach line in this file and how do i then split up my varables? i think it is something like


$file = file("photos.pmf")

foreach($line ($file)){

link($var1,$var2) = split("/*/*/", $line);

echo "<img src='".$var1."' atl='".$var2."' />".$var2."";
}

but i am not sure hence the asking for help, thanks in advance.

Alan

scriptmasterdel

5:33 pm on Sep 6, 2006 (gmt 0)

10+ Year Member



Something like this:

<?php
$lines = file('photos.pmf');

foreach ($lines as $line_num => $line)
{
$tmp = explode('/*/*/', $line);
$file = $tmp[0];
$title = $tmp[1];

echo '<img src="dir/to/images/'.$file.'">'.$title.'<br />';

}
?>

I chose explode as personal preference you should be able to use split if you prefer.

Good luck

Del

Kings on steeds

10:26 pm on Sep 6, 2006 (gmt 0)

10+ Year Member



Thanks, Worked A Charm. explode seemed to be the better option.

thanks again!