Your Ad Here

Posted By

plindsay on 09/18/08


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

oriolfb
jamesming
carlosabargues


getParentDirName()


 / Published in: PHP
 

retrieve the name of the parent directory

  1. function getParentDirName($path = null) {
  2.  
  3. if (!isset($path)) $path = $_SERVER['PHP_SELF'];
  4. $dir_path = dirname($path);
  5.  
  6. if (ereg('/', $dir_path)) {
  7. $dir_path_bits = array_reverse(explode('/', $dir_path));
  8. return $dir_path_bits[0];
  9. } else {
  10. return $dir_path;
  11. }
  12. }

Report this snippet  

You need to login to post a comment.