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> | "; Quote Link to comment Share on other sites More sharing options...
no_one Posted June 29, 2007 Share Posted June 29, 2007 $filename = str_replace('-',' ', $filename); Quote Link to comment 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>"; ?> Quote Link to comment 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> | "; ?> ? Quote Link to comment 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 ^ Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted June 29, 2007 Author Share Posted June 29, 2007 thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.