0

I have a image path like this..

2012/12/14/example.jpg

Now I would like to get the path except image name..

I mean I need like this

2012/12/14/

Can anyone help me? Thanks

hakre
  • 193,403
  • 52
  • 435
  • 836
Giri
  • 4,849
  • 11
  • 39
  • 48
  • http://php.net/dirname - Related: [How to get file name from full path with PHP?](http://stackoverflow.com/questions/1418193/how-to-get-file-name-from-full-path-with-php) – hakre Apr 02 '13 at 08:41

1 Answers1

1

I guess this is what you need

<?php
$path_parts = pathinfo('2012/12/14/example.jpg');

echo $path_parts['dirname'], "\n";
echo $path_parts['basename'], "\n";
echo $path_parts['extension'], "\n";
echo $path_parts['filename'], "\n"; 
?>

output will be..

   /www/htdocs/inc
    example.jpg
    jpg
    example
mr. Holiday
  • 1,780
  • 2
  • 19
  • 37