...

View Full Version : How to print upper folder PHP



coolabhi
03-01-2009, 04:39 PM
Hello can anyone tell me how to print upper folder in PHP from the file which is located in sub folder..

eg: public_html / mysite / music / new / index.php



$home = 'http://mysite.com/';
$current_folder = basename(dirname(__FILE__));
echo '<a href="'.$home.'">Home</a> / <a href="'.$home.$current_folder.'">'.$current_folder.'</a><br/>';


In this code I can link to currennt folder 'new' but how do I link 'music' folder in this script..

Pls Help... :( Tnx n advance :)

abduraooft
03-01-2009, 04:44 PM
Like

echo '<a href="'.$home.'">Home</a> / <a href="'.$home.$current_folder.'">'.$current_folder.'</a><br/>'; since the php variable won't get parsed, when used inside single quotes.

coolabhi
03-01-2009, 04:47 PM
Like

echo '<a href="'.$home.'">Home</a> / <a href="'.$home.$current_folder.'">'.$current_folder.'</a><br/>'; since the php variable won't get parsed, when used inside single quotes.

Aww thanks corrected.. can any1 help me out.......

abduraooft
03-01-2009, 05:08 PM
$path="public_html/mysite/music/new/index.php";
$dirs=explode('/',$path);
#print_r($dirs);
echo $parent=$dirs[count($dirs)-3];



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum