22 November 2016
Snippet shows you how to get filename from a path in PHP. Filename and extension separately. Can be used for extending filenames with timestamp or anything.
Source code viewer
- $bg = pathinfo($path);
- // Filename and extension separately, useful for extending filenames.
- echo $bg['filename'] . '.' . $bg['extension'];
- // Full filename.
- echo $bg['basename'];
- Programming Language: PHP