Loop through directories and look for directory name in PHP
Im trying to make a truncate system.

I want to permanent delete whole directores that are older than 14 days. The directories are named with dates in this format: dd-mm-yyyy

    $path = "sites/sitename/.trash/";
    $lastDate = date('Y-m-d', strtotime("+14 days"));

Is what i currently have. Which get the date in 14 days. I would like now to loop through the directories and check their names if they match $lastDate or are over that date.


So it would be something like:

    if($pathName >= $lastDate) { $this->deleteDir($pathName); } 

How can i do this? Looping through and check for their directories names, inside my $path (.trash/ directory where all the other date-named directories exists)
Loop through directories and look for directory name in PHP
===

Im trying to make a truncate system.

I want to permanent delete whole directores that are older than 14 days. The directories are named with dates in this format: dd-mm-yyyy

    $path = "sites/sitename/.trash/";
    $lastDate = date('Y-m-d', strtotime("+14 days"));

Is what i currently have. Which get the date in 14 days. I would like now to loop through the directories and check their names if they match $lastDate or are over that date.


So it would be something like:

    if($pathName >= $lastDate) { $this->deleteDir($pathName); } 

How can i do this? Looping through and check for their directories names, inside my $path (.trash/ directory where all the other date-named directories exists)