Page 1 of 1

stripping extensions

Posted: Fri Jun 25, 2004 12:39 am
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...

Posted: Fri Jun 25, 2004 12:42 am
by markl999

Code: Select all

$val = substr($val, 0, strrpos($val, '.'));

great

Posted: Fri Jun 25, 2004 12:51 am
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. :)