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, 1353👍, 0💬
Popular Posts:
Where to find tutorials on JSON (JavaScript Object Notation) text string format? I want to know how ...
How to access Request body from "context.Request.Body" object in Azure API Policy? Request body is t...
How to login to the Developer Portal internally by you as the publisher? Normally, the Developer Por...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...