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, ∼5474🔥, 0💬
Popular Posts:
How To Read the Entire File into a Single String in PHP? If you have a file, and you want to read th...
Where to find tutorials on Microsoft Azure services? Here is a large collection of tutorials to answ...
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...
Where to find tutorials on Using Azure API Management Developer Portal? Here is a list of tutorials ...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...