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, ∼5598🔥, 0💬
Popular Posts:
How to register and get an application ID from Azure AD? The first step to use Azure AD is to regist...
How to create a "Sign-up or Sign-in" user flow policy in my Azure AD B2C directory? If you want to b...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...
What is Azure API Management Publisher Dashboard? Azure API Management Publisher Dashboard is an Azu...
Where to get the detailed description of the json_encode() Function in PHP? Here is the detailed des...