Home Tutorial Php Phpfiles PHP pathinfo() Function and example

 
 

PHP pathinfo() Function and example
Posted on: October 30, 2009 at 12:00 AM
In this part of the tutorial we will learn about the function pathinfo() in context of file handling. And also we will see the example related to the pathinfo() function

Syntax for PHP pathinfo() Function
Array pathinfo(file_path,other options)

  • pathinfo() function returns the dir, base name, extension, and file name.
  • It returns dir, base name, extension etc in the form of the array of the given file.


PHP pathinfo() Function with Example

Code/Syntax of PHP pathinfo() Function

<?php
    $ar1
=pathinfo("aa.txt");
    foreach
($ar1 as $k=>$v)
       {
      echo
$k."->".$v."<br/>";
       }
?>


Output

dirname->.
basename->aa.txt
extension->txt
filename->aa

Related Tags for PHP pathinfo() Function and example :


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.