i want to make delete-list but except mp3 and mp4 file
my code is
error Fatal error: Call to undefined function endsWith() in E:\xampp\htdocs\tes\index.php on line 39
    $files = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($rootPath),
    RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
    // Skip directories (they would be added automatically)
    if (!$file->isDir())
    {
        // Get real and relative path for current file
        $filePath = $file->getRealPath();
        $relativePath = substr($filePath, strlen($rootPath) + 1);
        // Add current file to archive
        $zip->addFile($filePath, $relativePath);
        $zip->close();
        // Add current file to "delete list"
        // delete it later cause ZipArchive create archive only after calling close function and ZipArchive lock files until archive created)
        if ($file->getFilename().endsWith(".mp3")) error at this code
        {
            $filesToDelete[] = $filePath;
        }
    }
}
anyone help me please
 
     
    