trochia Posted December 29, 2008 Share Posted December 29, 2008 This post is based on the following [solved] thread, and as requested...shall be opened in a new topic. // http://www.phpfreaks.com/forums/index.php?topic=145174 Object: I have quite a few files, in both .txt (delimited by \n ) and *.csv files I would like to append to both the front of the string, and also at the end of the string. Some, I would like to do both at the same time, but if I may get the example clarified... i think I will be able to create the functions properly. Present Code: $myFile = "testFile.txt"; //assign variable to the file to work on $fh = fopen($myFile, 'r') or die("Can't open file"); //$theData = fread($fh, filesize($myFile)); //1 char = 1 byte. or get all with file size $theData = fgets($fh); // reads to the first new line \n" fclose($fh); // Echo to screen the contents echo $theData; But where I am lost in then trying to apply (from other thread) As I need to "look to the newlin, and do my actions either appending to the front or the back... //Get for appending //$tmp = ''; //Create Variable to store pulled array //for ($i = 0; $i < $appendString; $i = $i + 1) // $ //fclose($appendString); // Close the file Thx all for looking, jim 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.