Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I just want to display the name of my images, without the path (../uploadedImages/)
../uploadedImages/
<?php $images = glob("../uploadedImages/[kK]*.{jpg,png,gif,bmp}",GLOB_BRACE); foreach($images as $image) {echo "$image<br>"} ?>
chdir()
Use basename
basename
echo basename($image) . "<br>";
Add a comment
$files = array_map('basename', $files);
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__ .'/*' ) );
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
chdir(), you can omit the path from the result strings.