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, 1622🔥, 0💬
Popular Posts:
How to add images to my EPUB books Images can be added into book content using the XHTML "img" eleme...
How to use the "rewrite-uri" Policy Statement for an Azure API service operation? The "rewrite-uri" ...
How To Create an Array with a Sequence of Integers or Characters in PHP? The quickest way to create ...
How to login to Azure API Management Publisher Dashboard? If you have given access permission to an ...
What is the "__init__()" class method? The "__init__()" class method is a special method that will b...