Posted By


plindsay on 09/18/08

Tagged


Statistics


Viewed 176 times
Favorited by 1 user(s)

getParentDirName()


/ Published in: PHP
Save to your folder(s)

retrieve the name of the parent directory


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.