Re: adding a symbol in front of each line

From: Date: Thu, 18 Nov 2004 09:04:14 +0000
Subject: Re: adding a symbol in front of each line
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-202395@lists.php.net to get a copy of this message
Jason Wong wrote:
On Wednesday 17 November 2004 23:15, Merlin wrote:
actually that is not as easy as it looks.
Nowhere in your original post did you specify what exactly it is you wanted.
Lets say we want to ad a \n after each 80 characters. There is always the problem what happens if the line has already a \n inside. E.g: This is a sample text. This is a sample text. This is a sample text Should result in:
This is a sample text. This is a sample text. This is a sample text
That looks very complicated to me. Can anybody point me into the right direction? Thanx for any help,
If it's only one level of '>' that you need to add then it's pretty easy using the wordwrap() function. If you need to handle multiple levels then it will get very complicated, and you should probably google for some algorithms.
Now that was an excellent hint! Thank you. Here is how the problem got solved: $message = "\n> ".wordwrap($row->message, 70, "\n> "); http://de2.php.net/wordwrap Thank you Jason! Merlin

« previous php.general (#202395) next »