View previous topic :: View next topic |
Author |
Message |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Oct 25, 2005 4:03 am Post subject: Path with File Problem [Solved] |
|
|
This was currently a problem with trying to remove a file name from the path.
Whats even funnier is that I did'nt need to do this because its a Index Listing
script that will be used in ::File Limit:: v2. Aprelium can delete this :-)
Thanks for those who've already helped me with this issue.
Sincerely , TRUSTpunk
Last edited by TRUSTAbyss on Tue Oct 25, 2005 5:43 am; edited 1 time in total |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Tue Oct 25, 2005 4:18 am Post subject: |
|
|
It's not really tidy, and I'm not really awake, but something like this might work.
Code: | function removefilename($input) {
$dir = explode("/", $input);
for ($count = 1, $dir_result = "/"; ($count+1) < count($dir); $count++) {
$dir_result .= $dir[$count]."/";
}
return $dir_result;
}
$dir = dirname(removefilename("/music/rock/offspring/*file.mp3*"));
echo "Parent Directory: ".$dir; |
(Can't be arsed to put it into theory, 'tis 4AM.) _________________
 |
|
Back to top |
 |
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Oct 25, 2005 4:28 am Post subject: |
|
|
I edited my first post to explain how stupid this issue is. I did'nt have it
in my brain at the time that this is going to be a Directory Listing script.
Code: |
<?php
/*
This code will get the Parent Directory , which is
useful when you create a Directory Listing script.
*/
$dir = "/music/rock/offspring/";
echo "Parent Directory: " . dirname($dir);
// Will return /music/rock
?>
|
Note: If you ever create a Directory Listing script , you have to do more than
just add this piece of code in order to make it bug free , this code works. :-)
Sincerely , TRUSTpunk
Last edited by TRUSTAbyss on Tue Oct 25, 2005 5:48 am; edited 6 times in total |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Tue Oct 25, 2005 4:32 am Post subject: |
|
|
Apparantly I do things the hard way. Not seen that function before, either. _________________
 |
|
Back to top |
 |
 |
|