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
  • 184,866
  • 48
  • 414
  • 792
Giri
  • 4,709
  • 11
  • 36
  • 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,750
  • 2
  • 18
  • 37