"Roland Dalmulder" <rdalmuldernospamhotmail.com> wrote in
I assume you're writing to your text file line by line when you save it> Hello all,
> In my PHP script I put a text file into a string. Part of that string
> is read, changed and removed. The while loop continuest to extract the
> next part of the string. This goes all fine with one exception. When
> there is a line break in the second string that has the extract of the
> first string, it cannot find the words I am looking for as it stops
> looking when it hits the line break.
> For example:
> string = why is that line break there
> string2 = that line
> I am looking for "that line break", it can't find it with stristr.
> Which function can I use on the second string to have the line break
right? Are you appending \n after each line?
What's probably happening is when you read it back in, you're not
stripping the \n's out before working with your strings.
You do your string thing and then write the file back to disk - adding
*another* set of \n's.
Read it in, add more \n's.. pretty soon you'll have a VERY easy to read
doent. Page and a half line spacing!
While your reading in your text file (or going through the array created
by file(), etc), strip out the CRLF's:
$string = str_replace("\r", "", $string);
$string = str_replace("\n", "", $string);