How does PHP delete all files in the specified directory (keep the directory)?

ask, how does PHP delete all files in the specified directory (keep the directory)?

Php
Mar.01,2021

<?php
$src = '';
$d = new RecursiveDirectoryIterator($src);
$i = new RecursiveIteratorIterator($d);
foreach ($i as $name => $file) {
    // unlink
    if (!is_dir($name)) {
        unlink($name);
    }
}
Menu