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, ∼5868🔥, 0💬
Popular Posts:
How to install "The Windows SDK version 8.1"? I need to build my Visual Studio C++ applications. If ...
Where to find tutorials on HTML language? I want to know how to learn HTML. Here is a large collecti...
How to use "link" command tool to link objet files? If you have object files previously compiled by ...
How to use the "Ctrl-p Ctrl-q" sequence to detach console from the TTY terminal of container's runni...
Where to find EPUB Sample Files? Here is a list of EPUB sample files collected by FYIcenter.com team...