Hi there,
I have a flat file that contains file information that I want to publish as a photo album, which looks like this:
thumb1.jpg|file1.jpg|Alt Text 1
thumb2.jpg|file2.jpg|Alt Text 2
thumb3.jpg|file3.jpg|Alt Text 3
thumb4.jpg|file4.jpg|Alt Text 4
thumb5.jpg|file5.jpg|Alt Text 5
thumb6.jpg|file6.jpg|Alt Text 6
I want to read this file and generate the HTML for the thumbnails and photo links. So, here's what I tried:
$filename = "photos.txt";
$photodata = array();
$file=file($filename);
foreach($file as $line) {
$photodata[] = explode('|',$line);
echo '<a href="'.$photodata[0][0].'"><img src="'.$photodata[0][1].'" alt="'.$photodata[0][2].'" /></a>';
}
But this doesn't work. I would like it to print out like this:
<a href="file1.jpg"><img src="thumb1.jpg" alt="At Text 1" /></a>
<a href="file2.jpg"><img src="thumb2.jpg" alt="At Text 2" /></a>
<a href="file3.jpg"><img src="thumb3.jpg" alt="At Text 3" /></a>
<a href="file4.jpg"><img src="thumb4.jpg" alt="At Text 4" /></a>
The array has populated correctly and I can call individual items but I'm not sure how to have them all incremented to achieve the above.
Any ideas?
Thanks.