Hi.
You could set up a loop, searching for \n characters using the
strpos() function, which would give you their position. Meanwhile, you could use the
substr_replace() function, inside the loop, to replace each of the new-line characters with an integer that is incremented each time.
If that's complete gibberish, please let me know and I'll try to rephrase.