Tools, FAQ, Tutorials:
Retrieving Directory Name from File Path Name in PHP
How To Get the Directory Name out of a File Path Name in PHP?
✍: FYIcenter.com
If you have the full path name of a file, and want to get the directory name portion of the path name, you can use the dirname() function. It breaks the full path name at the last directory path delimiter (/) or (\), and returns the first portion as the directory name. Here is a PHP script example on how to use dirname():
<?php
$pathName = "/temp/download/todo.txt";
$dirName = dirname($pathName);
print("File full path name: $pathName\n");
print("File directory name: $dirName\n");
print("\n");
?>
This script will print:
File full path name: /temp/download/todo.txt File directory name: /temp/download
⇒ Splitting a File Path Name into Parts in PHP
⇐ Reading Directory Entries in PHP
2016-11-20, ∼2269🔥, 0💬
Popular Posts:
How To Convert a Character to an ASCII Value? If you want to convert characters to ASCII values, you...
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
How to add request query string Parameters to my Azure API operation 2017 version to make it more us...
How to convert JSON Objects to PHP Associative Arrays using the json_decode() function? Actually, JS...