E
E
Endru2015-06-23 15:29:24
PHP
Endru, 2015-06-23 15:29:24

Fancybox how to solve loop issue?

Hello. The situation actually is as follows:
I had a photo gallery in html using Fancybox.
I decided to transfer all the links to a text file, load them and run them in a loop.
Now if, when outputting, write

<a class="gallery" rel="sertifikat" href="<?php echo "/images/".$i?>">

When switching, the picture opens in a new window, and if so, then everything works:
<a class="gallery" rel="sertifikat" href="<?php echo "/images/1-lightbox.jpg"?>">

Here is the loop code:
<?php
$file = fopen("/images/certificates.txt", 'r');
$s=0;
if($file)
{
  while(!feof($file))
  {
    $i = fgets($file, 1024);
?>

<div class="superbox-list">
<a class="gallery" rel="sertifikat" href="<?php echo "/images/1-lightbox.jpg"?>">
<img src="<?php echo "/images/".$i?>" data-img="<?php echo "/images/".$i?>" alt="" class="superbox-img">
</a>
</div>




<?php
  }
}
fclose($file);
?>

What could be the problem ? Whether it is possible to solve somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2015-06-23
@EndruAN

Well, troubles ....
Make it easier.

<?php
$lines = file('/images/certificates.txt', FILE_IGNORE_NEW_LINES);
foreach ($lines as $line) {
    // $line - строка из из файла

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question