MRGRIM Posted January 25, 2008 Share Posted January 25, 2008 $output = "#EXTM3Un#EXTINF:".$filelength.",".urldecode($_GET['play'])."n".str_replace("/", "", urldecode($_GET['folder']))."".urldecode($_GET['play']); $newfile='live.m3u'; $file = fopen ($save_path.$newfile, "w"); fwrite($file, $output); fclose ($file); I am trying to write the $output to a file named live.m3u, however when the code executes it all ends up on the same line with a [] instead of a carridge return, the text it outputs is fine and if I manually open the file and put the code on 3 lines the .m3u will open. I have tried a couple of things but I can't seem to get n to work, does anyone have any suggestions? Not sure if this should have gone into coding? Quote Link to comment Share on other sites More sharing options...
digip Posted January 25, 2008 Share Posted January 25, 2008 try rn instead of n and see what that does. Quote Link to comment Share on other sites More sharing options...
MRGRIM Posted January 25, 2008 Author Share Posted January 25, 2008 :-P Nice one fella, works a treat off to find out what /r does Quote Link to comment Share on other sites More sharing options...
digip Posted January 25, 2008 Share Posted January 25, 2008 :-P Nice one fella, works a treat off to find out what /r does Are you on Windows or Linux/mac? I think n works as a replacement to <br> when doing echo statments for html, but rn is when streaming data to a file. On a MAC rn works like n on windows and linux for html <BR> though. Quote Link to comment Share on other sites More sharing options...
jollyrancher82 Posted January 25, 2008 Share Posted January 25, 2008 Windows, Linux, and OSX interpret n and rn differently, some assume r with n. Quote Link to comment Share on other sites More sharing options...
xero Posted June 14, 2012 Share Posted June 14, 2012 (edited) windows uses \r\n and linux is \n but for simplicity's sake, just use the php constant PHP_EOL (since 4.3.10 and 5.0.2) cite the server decides what the correct line ending is for it's environment and uses it. enjoy! Edited June 14, 2012 by xero Quote Link to comment Share on other sites More sharing options...
digip Posted June 14, 2012 Share Posted June 14, 2012 windows uses \r\n and linux is \n but for simplicity's sake, just use the php constant PHP_EOL (since 4.3.10 and 5.0.2) cite the server decides what the correct line ending is for it's environment and uses it. enjoy! Nice! Thanks for that. 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.