Skip to content
Advertisement

Get name of subfolder with highest number

A folder ‘archive’ contains lots of numbered sub-folders (starting with 1 and increasing by one weekly, currently 122) like this:

JavaScript

On my homepage (ROOT/index.php) I’d like to show the number of the subfolder with the highest number, so currently ‘122’. I just need to display that number. How do I do that? Thanks for your help!

Advertisement

Answer

A quick and dirty snippet to find the highest numbered directory in archive. You’ll need to set the right path to your archive and add some error handling.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement