Jump to content

Simple image sorting


murratw

Recommended Posts

I need help modifying the following code.

 

The following code displays the latest 15 images in reverse chronological order. I would like to display the latest 15 images in random order.

Can someone help me modify?

 

<?php



//Your folder

$files = glob("images/*.*");



function sortnewestfilesfirst($a, $b) {

    return filemtime($b) - filemtime($a);

}

usort($files, "sortnewestfilesfirst");



$colCnt=0;

echo '<table border="0" style="width:2000px;">';



for ($i=0;$i<15;$i++)

  {

  $colCnt++;

  if ($colCnt==1)

  echo '<tr>';

  echo '<td width="20%" style="font-size:8.5px; font-family:arial">';



  $num = $files[$i];

   

echo ' 

  <div class="ImgBorder">

   <div class="clipout">

    <div class="clipin"> <a href="' . $num . '" rel="lightbox[all]"><img class="thumb ImgBorder" src="'.$num.'">  

</a> </div>

   </div></div>'."  ";





  echo '</td>';



  if ($colCnt==2)

    {

    echo '</tr>';

    $colCnt=0;

    }

  }



echo '</table>';

?>

Link to comment
https://forums.phpfreaks.com/topic/264765-simple-image-sorting/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.