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, 3666🔥, 0💬
Popular Posts:
How to create a new API on the Publisher Dashboard of an Azure API Management Service? If you are ne...
Why am I getting this "Docker failed to initialize" error? After installing the latest version of Do...
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to lo...
How to view API details on the Publisher Dashboard of an Azure API Management Service? You can follo...
How to use the "set-variable" Policy Statement to create custom variables for an Azure API service o...