Using Stats in Php

So, I have a php program that i need to delete ALL files in a directory that are older than a certain age.

<?php
/* Get file stat */
$stat = stat('/apps/security/ajaba');

This is as far as I've been able to get. I know in shell programming you can easily do something like this. but I'm clueless here with this script.

thanks

Why not use one of the PHP: Program execution Functions to call find and use the find -exec argument to delete them?

It is not difficult to do this in PHP. There is no need to call an external shell function.

---------- Post updated at 19:03 ---------- Previous update was at 18:07 ----------

Hints:

  • filemtime()
  • unlink()

Hint Hint: PHP online man page for unlink() at php.net has example using filemtime() and unlink() to remove files older than 3600 seconds (last modification time) in a directory.