Information about a file path in PHP
PHP has a wonderful function which tells us about the file path,extension and directory names. The function name is pathinfo(). Below is the code snippet. Give a try on your system
$path_parts = pathinfo('/www/htdocs/index.html');
echo $path_parts['dirname'], "\n"; //Output is /www/htdocs
echo $path_parts['basename'], "\n"; //Output is index.html
echo $path_parts['extension'], "\n";
//Output is html
echo $path_parts['filename'], "\n"; // since PHP 5.2.0 //Output is index
?>
Labels: filepath information in php, php
posted by adityachandra @ 10:36 PM,
Post a Comment