I currently have a text file that needs to be formatted in a certain way (each line must be 100 chars total) - if the data isn't 100 chars, it should be padded with spaces... So, this is the code I have at the moment - i'm reading a file line by line, padding it out and writing it back to another file...
$LineData = fgets($file);
$PaddedLineData = str_pad($LineData, 100," ",STR_PAD_RIGHT);
$FinalLineData = $PaddedLineData . "\r\n";
That ALMOST works..... this is what the new txt file looks like:
line of data 1
(correct amount of padding for line 1)
line of data 2
(correct amount of padding for line 2)
-the padding is on the second / fourth line - not the first and second - it is however, the correct amount of padding...
Can anyone suggest how to fix this and get the padding on the correct lines?