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... Quote Link to comment 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>"; ?> Quote Link to comment 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. Quote Link to comment 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>"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.