al3x8730 Posted September 2, 2008 Share Posted September 2, 2008 I'm currently using this: <?php $handle=opendir("."); while (($file = readdir($handle))!==false) { echo "$file <br>"; } closedir($handle); ?> To view the contents of a directory. If I want all the .php extensions not to show on the list how would I go about doing that? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/122329-getting-rid-of-extensions-in-directory-listing-quick-help-needed/ Share on other sites More sharing options...
Third_Degree Posted September 2, 2008 Share Posted September 2, 2008 simply put: echo str_replace( ".php", "", $file ) . " <br />"; Link to comment https://forums.phpfreaks.com/topic/122329-getting-rid-of-extensions-in-directory-listing-quick-help-needed/#findComment-631662 Share on other sites More sharing options...
trq Posted September 2, 2008 Share Posted September 2, 2008 echo substr($file,0,strrpos($file,'.')) . "<br />"; Link to comment https://forums.phpfreaks.com/topic/122329-getting-rid-of-extensions-in-directory-listing-quick-help-needed/#findComment-631663 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 simply put: echo str_replace( ".php", "", $file ) . " <br />"; That doesn't work, I might be putting it in the wrong place, but I doubt it, where should I put it? Link to comment https://forums.phpfreaks.com/topic/122329-getting-rid-of-extensions-in-directory-listing-quick-help-needed/#findComment-631668 Share on other sites More sharing options...
Third_Degree Posted September 2, 2008 Share Posted September 2, 2008 replace the line: echo "$file <br>"; try thorpe's solution or the explode() function. Link to comment https://forums.phpfreaks.com/topic/122329-getting-rid-of-extensions-in-directory-listing-quick-help-needed/#findComment-631669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.