nesiak Posted May 23, 2007 Share Posted May 23, 2007 I've made this function to replace spaces with "-" and it doesn't work what did i do wrong? <?php $string = "Go for it now"; echo $string; function change($str) { while ($a!=strlen($str)); { $ss =fgetc($file); if ($ss==" ") { $ss = "-"; } $ok = $ok+$ss; $a++; echo $ok; echo $a; } } change($string); ?> Quote Link to comment Share on other sites More sharing options...
chigley Posted May 23, 2007 Share Posted May 23, 2007 Instead of all that; why not use this? <?php $string = "Go for it now"; $string = str_replace(" ", "-", $string); echo $string; // Go-for-it-now ?> Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted May 23, 2007 Share Posted May 23, 2007 D'oh chigley beat me to it! Quote Link to comment Share on other sites More sharing options...
nesiak Posted May 23, 2007 Author Share Posted May 23, 2007 Hahaha, thanks ! 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.