I have a string called $file_path; for a php gallery, When I make <?php echo $file_path; ?> "gallery/png.png", "gallery/jpg.jpg", "gallery/gif.gif" etc, for all img files on that directory. I want to remove "gallery/" and ".format" for the $file_path;.
4 Answers
echo basename($file_path,".png");
basename will return only the file name
really a third version of the question, next time work out what you want to ask first please:
echo pathinfo($file_path, PATHINFO_FILENAME);
this will echo "file" if $file_path is "gallery/file.jpg"
try this
str_replace('gallery/', '', $file_path);
1 Comment
CodeingBoy
@Kake you can use str_replace('.png', '', $file_path);