I want to do following 2 things 1)i want retrive the list of all files in a directory 2)and then i want to remove their extensions
eg: if i get a list of fils as A.png ,B.png,C.jpeg,D.txt I want to get A,B,C,D
How do i do that in php?
I want to do following 2 things 1)i want retrive the list of all files in a directory 2)and then i want to remove their extensions
eg: if i get a list of fils as A.png ,B.png,C.jpeg,D.txt I want to get A,B,C,D
How do i do that in php?
<?php
foreach (new DirectoryIterator('directory') as $fileInfo) {
if($fileInfo->isDot()) continue;
$regex = '/\.\w+/';
echo preg_replace( $regex, '', $fileInfo->getFilename() ) . '<br>';
}
function filename_part($f) {
return pathinfo($f, PATHINFO_FILENAME);
}
$result = array_map("filename_part", scandir($directory));