# Get parent directory, with a twist

**URL:** <https://forum.kirupa.com/t/get-parent-directory-with-a-twist/318834>\
**Category:** Uncategorized\
**Created:** [February 1, 2011, 1:27am UTC](https://forum.kirupa.com/t/get-parent-directory-with-a-twist/318834 "2011-02-01T01:27:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyg3r](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tyg3r/32/1341_2.png) [@Tyg3r](https://forum.kirupa.com/u/Tyg3r)\
**Post date:** [February 1, 2011, 1:27am UTC](https://forum.kirupa.com/t/get-parent-directory-with-a-twist/318834/1 "2011-02-01T01:27:09Z")

</div>

Hi

I’m trying to run a function within the index.php directory that will return “directory2” as a variable/string…

> [http://www.website.com/directory1/directory2/directory3/index.php](http://www.website.com/directory1/directory2/directory3/index.php)

I’ve tried using: dirname(dirname( **FILE** ));

However, the function to return that parent directory is imported from an entirely separate php file of it’s own (quickfunctions.php). The dirname command only returns the parent directory from the php file that holds the function. I need it to return the parent directory of the index.php.

And ideas?
