Hi all,
I've got a page where I'm displaying images from a directory. The images are labled 1.jpg through 524.jpg. This will never change (i.e. names or numbers of images in this directory).
What i've added is a file that contains 'subtitles' to each image. It's just a text file in this format:
1|some words for image 1
2|some words for image 2
...etc
This is the code im using to display the subtitle with the appropriate image:
$subTitles "some/path/to/the/textFile";
$fo = fopen($subTitles, 'r');
if ($fo) {
while (!feof($fo)) {
$fContents = fgets ($fo,4096);
list($fImgNum,$subtitle) = split ("\|",$fContents);
if ($fImgNum == $imgNum) {
echo $subtitle;
break;
}
}
fclose ($fo);
} else {
echo "Error opening the subtitles file";
}
this works fine for my purposes.
I'm wondering though, is there a way to fopen(), or file() then go directly to a specified line number instead of going through the file line by line until the current image/line number is reached? I realize that 524 lines is pretty tiny, but it just seems like there is a more 'direct' way to the line number needed?
Thanks.