Reputation: 117
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>"} ?>
Upvotes: 10
Views: 11067
Reputation: 123
Although basename is good for a single file, if you need to cut the path for several files that glob gives as array, this way works great.
$contents = str_replace( __DIR__, '', glob( __DIR__ .'/*' ) );
Upvotes: 1