KingOfHeart Posted October 24, 2010 Share Posted October 24, 2010 I got this script to replace all the lines with a * to a name. It looks like it works but there's no line breaks when it outputs. <? $fp = fopen("temp.txt", "r"); $buffer = fread($fp, 120000); fclose($fp); $lines = explode("\n", $buffer); $t = 1; $n = 0; while($n < 939) { if(substr($lines[$n],0,1) == "*") { $lines[$n] = "o_tile1" . $t . "\n"; $t++; //echo $lines[$n]; } $n++; } //return; $fp = fopen("temp.txt", "w"); $buffer = implode("\n", $lines)."\n"; fwrite($fp, $buffer); fclose($fp); ?> What did I do wrong? Quote Link to comment Share on other sites More sharing options...
revraz Posted October 25, 2010 Share Posted October 25, 2010 Did you try \n \r ? Quote Link to comment Share on other sites More sharing options...
KingOfHeart Posted October 25, 2010 Author Share Posted October 25, 2010 Finally got the right combo. <? $fp = fopen("temp.txt", "r"); $buffer = fread($fp, 120000); fclose($fp); $lines = explode("\r\n", $buffer); $t = 1; $n = 0; while($n < 939) { if(substr($lines[$n],0,1) == "*") { $lines[$n] = "o_tile1" . $t; $t++; //echo $lines[$n]; } $n++; } //return; $fp = fopen("temp.txt", "w"); $buffer = implode("\r\n", $lines); fwrite($fp, $buffer); fclose($fp); ?> 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.