[SOLVED] stripping extensions

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
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

stripping extensions

Post by fresh »

hello again,

im looking to readdir and echo the contents onto my main page like so:

Code: Select all

<?
$the_array = Array();
$handle = opendir('user/');
while (false !== ($file = readdir($handle))) &#123;
   if ($file != "." && $file != "..") &#123;
   $the_array&#1111;] = $file;
   &#125;
&#125;
closedir($handle);
sort ($the_array);
reset ($the_array);
while (list ($key, $val) = each ($the_array)) &#123;
   echo "<div style='border:#EFEFEF 1px solid;width:100;'>";
   echo "<center><a href='http://munday.t35.com/user/".$val."' style='text-decoration:none'><font color='#FFFFFF'>".$val."</font></a></center>";
   echo "</div>";
&#125;
?>
as you may see, this code will echo the exact contents, including the .htm extension... the contents represent the users who have joined my community, and I would like for the users names to be echoed on the page how it is now, but without the .htm extention... how would I incorporate that idea within the syntax of my script above?

thanks in advance...
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Code: Select all

$val = substr($val, 0, strrpos($val, '.'));
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

great

Post by fresh »

that did it, I was looking at that command, but I thought it was for only text within text files... duh... lol... thanks alot for your help. :)
Post Reply