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, ∼6586🔥, 0💬
Popular Posts:
How to validate the id_token signature received from Azure AD v2.0 authentication response? You can ...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How to call a function from a VC# class provided in a library? If you want to call a function from a...
Where to find tutorials on OpenID? Here is a large collection of tutorials to answer many frequently...