Jump to content

cyb-php

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by cyb-php

  1. Thanks "Barand", I solved the problem and it is almost like yours: $files = glob("layout/gallery/1thumbs/200x200/*.webp"); rsort($files, SORT_NATURAL); $rows=[]; while(count($files) != 0) { $splice = count($rows) % 2 == 0 ? 5 : 4; // This part resolves my problem! $rows[] = array_splice($files, 0, $splice); } foreach($rows as $row) { echo '<div class="stage stage_one">'."\n"; foreach($row as $file) { $fnames = pathinfo($file, PATHINFO_FILENAME); echo '<a data-fancybox="images" data-caption="'.$fnames.'" href="layout/gallery/'.$fnames.'/'.$fnames.'.webp" alt=""><img src="'.$file.'"></a>'."\n"; } echo '</div>'."\n"; }
  2. "gw1500se" and "requinix" thanks for reply, but the problem I am trying to solve is in PHP and not in HTML. The code is simplified there, I don't use <br> or <br /> at all on my pages. Obviously there will be a <div class="whatever"> around there. Thanks
  3. Hi I am trying to create a dynamic gallery in php with specific order of pictures on the page, but I can't find the function or piece of php code to do so. Conditions: 1. The gallery must be dynamic, pictures will be coming from a folder via php, because when I'll add/upload more pictures in the folder they must be displayed on the page without adding manually the html tags in. ( this part is easy, problem is the condition 2 ). 2. The first row will have 5 pictures, the second - 4 pictures (important for the specific effect). My code: $files = glob("layout/gallery/*.jpg"); rsort($files, SORT_NATURAL); for ($i=0; $i < count($files); $i++) { for( ; $i<5; $i++){ $one = $files[$i]; echo '<img src="'.$one.'">' . '<br><br>'; } echo "<br>"; for( ; $i<9; $i++){ $two = $files[$i]; echo '<img src="'.$two.'">' . '<br><br>'; } } The code works well, but it just displays 9 pictures obviously. I was unable to make it dynamic displaying 5 pictures first, 4 pictures after and stay this way in a loop till displays all pictures from that folder.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.