ballhogjoni Posted June 29, 2007 Share Posted June 29, 2007 How do I strip out the - in a file name and add a space in its place? example: 123-456.php I want it to print on a browser as: 123 456 echo "<a href=\"$PHP_SELF/articles/credit_repair/$filename\" target=\"_BLANK\">".substr($filename,0,strlen($filename)-4)."</a> | "; Link to comment https://forums.phpfreaks.com/topic/57750-solved-strip-out-of-file-name/ Share on other sites More sharing options...
no_one Posted June 29, 2007 Share Posted June 29, 2007 $filename = str_replace('-',' ', $filename); Link to comment https://forums.phpfreaks.com/topic/57750-solved-strip-out-of-file-name/#findComment-285926 Share on other sites More sharing options...
ballhogjoni Posted June 29, 2007 Author Share Posted June 29, 2007 Would that work in this array? <?php $noshow = array('add_edit_cards.php','config.php','index.php','bottom_content.php'); echo "<table align=\"center\"><tr><td align=\"center\">"; foreach (glob("*.php") as $filename) { if (in_array($filename,$noshow)) { continue; } echo "<a href=\"$PHP_SELF/articles/credit_repair/$filename\">".substr($filename,0,strlen($filename)-4)."</a> | "; } echo "</td></tr></table>"; ?> Link to comment https://forums.phpfreaks.com/topic/57750-solved-strip-out-of-file-name/#findComment-285929 Share on other sites More sharing options...
no_one Posted June 29, 2007 Share Posted June 29, 2007 <?php echo "<a href=\"$PHP_SELF/articles/credit_repair/$filename\">" . str_replace('-',' ',substr($filename,0,strlen($filename)-4)) . "</a> | "; ?> ? Link to comment https://forums.phpfreaks.com/topic/57750-solved-strip-out-of-file-name/#findComment-285931 Share on other sites More sharing options...
Dragen Posted June 29, 2007 Share Posted June 29, 2007 <?php $noshow = array('add_edit_cards.php','config.php','index.php','bottom_content.php'); echo "<table align=\"center\"><tr><td align=\"center\">"; foreach (glob("*.php") as $filename) { if (in_array($filename,$noshow)) { continue; } $filename = str_replace('-',' ', $filename); echo "<a href=\"$PHP_SELF/articles/credit_repair/$filename\">".substr($filename,0,strlen($filename)-4)."</a> | "; } echo "</td></tr></table>"; ?> EDIT: heh, beaten to it ^ Link to comment https://forums.phpfreaks.com/topic/57750-solved-strip-out-of-file-name/#findComment-285932 Share on other sites More sharing options...
ballhogjoni Posted June 29, 2007 Author Share Posted June 29, 2007 thank you Link to comment https://forums.phpfreaks.com/topic/57750-solved-strip-out-of-file-name/#findComment-285936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.