al3x8730 Posted September 2, 2008 Share Posted September 2, 2008 I'm using the simple script: <?php $handle=opendir("users/"); while (($file = readdir($handle))!==false) { echo str_replace( ".php", "", $file ) . " <br />"; } closedir($handle); ?> Now I want to add an ordered list to that. Is this possible? I tried adding it in around the $file in the echo, but it just repeats 1., 1., 1., etc... Link to comment https://forums.phpfreaks.com/topic/122388-solved-adding-ordered-list-to-a-directory-contents-list/ Share on other sites More sharing options...
Fadion Posted September 2, 2008 Share Posted September 2, 2008 Try this: <?php echo "<ol>"; foreach(glob("*.php") as $val){ $file = basename($file, '.php'); echo "<li>$file</li>"; } echo "</ol>"; ?> Link to comment https://forums.phpfreaks.com/topic/122388-solved-adding-ordered-list-to-a-directory-contents-list/#findComment-631957 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 Try this: <?php echo "<ol>"; foreach(glob("*.php") as $val){ $file = basename($file, '.php'); echo "<li>$file</li>"; } echo "</ol>"; ?> That doesn't work. It just shows the numbers, but now it doesn't show the name of the files. Link to comment https://forums.phpfreaks.com/topic/122388-solved-adding-ordered-list-to-a-directory-contents-list/#findComment-631959 Share on other sites More sharing options...
Fadion Posted September 2, 2008 Share Posted September 2, 2008 My bad, i did a variable mistake. Try this: <?php echo "<ol>"; foreach(glob("*.php") as $val){ $file = basename($val, '.php'); echo "<li>$file</li>"; } echo "</ol>"; ?> Link to comment https://forums.phpfreaks.com/topic/122388-solved-adding-ordered-list-to-a-directory-contents-list/#findComment-631962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.