Convert windows newlines to unix newlines
May 15, 2009
Author: Developer
This tutorial will show you how to convert windows system newlines
in UNIX system newlines. I hope will help you.
Here is some script from real live
This PHP Script allows you to upload a text file in with windows newline
characters, it wil then remove the "/r" char and output the newtext file to the browser.
<?php if ($_FILES['parse_file'] != "") { $file = file($_FILES['parse_file']['tmp_name']); $counter = count($file); $fp = fopen('newtext.txt', 'w+'); for ($x=0; $x <= $counter; $x++) { if(stristr($file[$x], "\r")) { fputs($fp, str_replace("\r", '', $file[$x])); } } header('Location: newtext.txt'); } else { ?> <form enctype="multipart/form-data" method="post" action="#"> <input type="hidden" name="MAX_FILE_SIZE" value="25000"> <p><strong>File to Upload:</strong><br> <input type="file" name="parse_file" size="30"></p> <input type="submit" name="submit" value="submit"> </form> <?php } ?>
views 5055