Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:28:30+00:00 2026-06-14T22:28:30+00:00

Using the below action I gather a list of files and display them. I

  • 0

Using the below action I gather a list of files and display them. I need to be able to sort the files by last modified date. Is there a simple way in PHP or using ZEND to order the items by last modified? If you know of a easier way to get the files and order them using ZEND; please let me know.

public function imagesAction()
{
    $this->_helper->layout->disableLayout();

    $results = array();

    $handler = opendir(APPLICATION_PATH . '/../public/images/blog');

    while ($file = readdir($handler)) {
        if ($file != "." && $file != ".." && $file != '.svn') {
            $results[] = $file;
        }
    }

    closedir($handler);

    $this->view->data = $results;
}

I have tried doing

$this->view->data = ksort($results);
$this->view->data = asort($results);

But those just remove the entire list of files from the view and they stop showing up.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:28:31+00:00Added an answer on June 14, 2026 at 10:28 pm
    public function imagesAction()
    {
        $this->_helper->layout->disableLayout();
    
        $results = array();
    
        $handler = opendir(APPLICATION_PATH . '/../public/images/blog');
    
        while ($file = readdir($handler)) {
            if ($file != "." && $file != ".." && $file != '.svn') {
                $results[] = array('file' => $file, 'time' => filemtime($file));
            }
        }
    
        closedir($handler);
    
        uasort($results, function($file1, $file2) {
            if ( $file1['time'] == $file2['time'] )
               return 0;
            return $file1['time'] < $file2['time'] ? -1 : 1;
        });
    
        $this->view->data = $results;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a form containing a button type shown below: <form method=post action=> <button
Analysing the code below in action through Fiddler, I realized that using Parallel Extensions
I have a left side navigation menu on my page.. using url.action like below..
I am using below code to display web page Uri uri = Uri.parse(http://myurl); Intent
I'm using the below line of code for the date select in a form_for
i am able to send mail using below my code ,but by default after
I am using the below code to browse and pick files from sd card.
Action buttons are added to jqGrid columns using colmodel below. Column width 45 is
Consider the below struts Action class in which, I am using a StringBuilder variable
Am using below third party API in my project development http://undesigned.org.za/2007/10/22/amazon-s3-php-class I have done

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.