Jump to content

Counting Files


Miles LLC

Recommended Posts

I know how to count the files:

<?php
$dir = $_SERVER[DOCUMENT_ROOT]."/api/sigs/cache/".$i[id]."/";
$files = scandir($dir);
$result = count($files);

printf("$result Signatures Generated");
?> 

 

But i'm trying to make it so it only counts the files that were modified recently (That Day).

Link to comment
Share on other sites

I know how to count the files:

<?php
$dir = $_SERVER[DOCUMENT_ROOT]."/api/sigs/cache/".$i[id]."/";
$files = scandir($dir);
$result = count($files);

printf("$result Signatures Generated");
?> 

 

But i'm trying to make it so it only counts the files that were modified recently (That Day).

 

 

Try reading up here: http://php.net/manual/en/function.filemtime.php

Link to comment
Share on other sites

scandir will also have the "files"  '.' (here) and '..' (parent directory), be sure to filter those out. The directory will more than likely see its modified time updated when one of its files does.

 

I like is_file for as well, because file_exists() on a directory will be TRUE.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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