Share on Google+Share on Google+

PHP pathinfo() Function and example

Ads
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

Advertisements

Ads

Posted on: October 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.