PHP get file name with extension
PHP get file name with extension
The script below will help using PHP to get file name with extension. We are using function named pathinfor(), filenames well as the directory name.This functions returns the path information in a array with the following elements dirname, basename and extension. Let’s look at the example of pathinfo() function first
< ?php $myweb = pathinfo('/root/websitename/index.html'); echo $myweb['basename'], "<br />"; echo $myweb['extension'], "<br />"; echo $myweb['dirname'], "<br />"; ?>
Let output of the above will be
index.html – This is file name
html – This is extension
/root/websitename/ –This is directory name
PATHINFO() -> http://www.php.net/pathinfo
PHP get file name with extension,