hi
I'm sure this is a very basic problem, but it's got me stumped, as i'm fairly new to php. I would be grateful for any help. I've read a .txt file into an array, using the file() command. i'm trying to trim all white space from the begining and end of each line which works ok, but it is also knocking off the newline symbol - should the newline symbol be this /n or /r ? - i've tried both in the code below, but neither works. after my trim command has been applied and the file saved as a text file again, where i want a text file like this:
first phrase
second phrase
third phrase
I get a .txt file like this:
first phrasesecond phrasethird phrase
so basically i want to remove white space from beging and end of each line as it's doing, but then add a new linesymbol. could anyone point me in the right direction. this is the code i'm using currently that doesn't work, i would prefer if possible to just modify slightly the code i have already if possible.
foreach ($linesraw3 as $key => $value) {
$linesraw3[$key] = trim($value);
$linesraw3[$key] = str_replace("$value", "$value/n", "$linesraw3[$key]");}
thanks in advance.
roland