Home » Php » php – How can I remove the file path when using Glob()?

php – How can I remove the file path when using Glob()?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I just want to display the name of my images, without the path (../uploadedImages/)

<?php $images = glob("../uploadedImages/[kK]*.{jpg,png,gif,bmp}",GLOB_BRACE);   
foreach($images as $image) {echo "$image<br>"} ?>
How to&Answers:

Use basename

echo basename($image) . "<br>";