Tools, FAQ, Tutorials:
Splitting a File Path Name into Parts in PHP
How To Break a File Path Name into Parts in PHP?
✍: FYIcenter.com
If you have a file name, and want to get different parts of the file name, you can use the pathinfo() function. It breaks the file name into 3 parts: directory name, file base name and file extension; and returns them in an array. Here is a PHP script example on how to use pathinfo():
<?php
$pathName = "/temp/download/todo.txt";
$parts = pathinfo($pathName);
print_r($parts);
print("\n");
?>
This script will print:
Array
(
[dirname] => /temp/download
[basename] => todo.txt
[extension] => txt
)
⇐ Retrieving Directory Name from File Path Name in PHP
2016-11-17, ∼5572🔥, 0💬
Popular Posts:
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not acce...
How to convert a JSON text string to an XML document with PHP language? Currently, there is no built...
Where to find tutorials on Python programming language? I want to learn Python. Here is a large coll...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...