title: Sort array and limit to four.
body: <p>Is there way to sort image by date and then limit to just four recent to show.</p>
  
  <pre><code> &lt;div class="row no-gutter"&gt;
          &lt;?php
          $dirname = "assets/img/portfolio/";
          $images = glob($dirname."*.jpg");
          $ignore = Array(".", "..");
  
          foreach($images as $curimg){
          $name2 =pathinfo($curimg, PATHINFO_FILENAME);
          if(!in_array($curimg, $ignore)) {};
  
          ?&gt;
  
  
          &lt;div class="col-sm-3 sm-margin-bottom-30"&gt;
              &lt;a href="&lt;?php echo "$curimg"?&gt;" rel="gallery4" class="fancybox img-hover-v2" title="&lt;?php echo "$name2"?&gt;"&gt;
                  &lt;span&gt;&lt;img class="img-responsive" src="&lt;?php echo "$curimg"?&gt;" alt=""&gt;&lt;/span&gt;
              &lt;/a&gt;
          &lt;/div&gt;
          &lt;?php }?&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>Thank you</p>