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, ∼2891🔥, 0💬
Popular Posts:
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...
Where to find tutorials on HTML language? I want to know how to learn HTML. Here is a large collecti...
How to Instantiate Chaincode on BYFN Channel? You can follow this tutorial to Instantiate Chaincode ...
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...