Re: adding a symbol in front of each line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux