Code Help Needed - modify script to only include .htm files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpnewbdude
Forum Newbie
Posts: 23
Joined: Thu Jun 23, 2005 8:07 am

Code Help Needed - modify script to only include .htm files

Post by phpnewbdude »

Is there anyway to modify this script to only include certain file types? I only want to display .htm files.

Code: Select all

<?php   exec("/bin/ls -t /home/yourwebsite/www/ | head -10",$s);   
for  ($i=0;$i  <  count($s);$i++)     
echo "<a href=\"http://www.yourwebsite.com/$s[$i]\">$s[$i]</a><br>\n"; ?>
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

You would be better of to use the core directory/file handling commands in PHP. Have a look here for more information.

If php has functions to do it, it is always safer than using an exec command and more system independant.
Post Reply