/    Sign up×
Community /Pin to ProfileBookmark

Determine if this folder is the last level within that folder?

Good day,
I’m working on a script and this script list folder in a html list.

Here is the code;

[code=php]

<html>

<head>

<style type=”text/css”>

ul {

list-style-image: url(Icons/box_icon.png);

}

li li {

list-style-image: url(‘Icons/open_book_icon.jpg’);

}

li li li {

list-style-image: url(‘Icons/gallery.gif’);

}

</style>

</head>

<body>

<?PHP

function globDir($dir)

{

$files = glob(“$dir/*”, GLOB_ONLYDIR);

if(!empty($files))

{

echo “<ul>n”;

foreach($files as $file)

{

echo “<li>”;

echo “<b>”. basename($file).”</b>n”;

globDir($file);

echo “</li>n”;

}

echo “</ul>n”;

}

}

globDir(‘Photos’);

?>

</body>

</html>

[/code]

example folder
|
– Folder 1
– Folder 2
|
– Folder2.1
|
– Folder3

The deal here is that I could go by CSS level of list but my problem is that sometime there is more subfolder yhat this example.

Is there a way that I can tell the last level folder to be written in bold ?

Thanks !

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SrWebDeveloperMar 01.2010 — Maybe instead of echoing your output directly, populate an array instead. Then after the foreach is done just find out how many total elements using count() and modify the last one as you see fit then output the array.
×

Success!

Help @Peuplarchie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...