You are here: Re: [PHP] formatting paragraphs in to strings « PHP « IT news, forums, messages
Re: [PHP] formatting paragraphs in to strings

Posted by Philip Hallstrom on 06/14/05 00:17

> Good point. Only problem is, if someone hit enter a-million times,
> you would end up with a-million spaces where the "\n" characters were.
> To take care of that repetition, maybe something like:
>
>
> while (strpos($textarea_text, "\n\n")) {
> .....
> }
>
>
> would be one way you could do it.

$new_str = ereg_replace("[\n\r]+", " ", $textarea_text);

would be another and avoid the loop as well at the expense of adding some
regexps :)


>
>
> On 6/13/05, Murray @ PlanetThoughtful <lists@planetthoughtful.org> wrote:
>>> Use the PHP str_replace function before writing it to the DB. Replace
>>> all "\n" characters with an empty string "".
>>>
>>> http://us2.php.net/manual/en/function.str-replace.php
>>
>> I think it might be better to replace all "\n" characters with spaces " ",
>> otherwise you will end up with sentences that have no space break between
>> them.
>>
>> Ie:
>>
>> <original text>
>> This is the first sentence.
>>
>> This is the second sentence.
>> </original text>
>>
>> ...would become:
>>
>> <replaced text>
>> This is the first sentence.This is the second sentence.
>> </replaced text>
>>
>> Regards,
>>
>> Murray
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация