Re: transfer list in textarea to comma delimited string

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

 



Stut wrote:
> On 2 May 2008, at 16:22, afan pasalic wrote:
>> I have one textarea field in a registration form where visitor enters
>> keywords. even there is a not next to the field "please enter keywords
>> as comma delimited string", they enter as  a list, below each other.
>>
>> I tried to convert the list into comma delimited string with several
>> solutions but non of them works:
>> $keywords = eregi_replace('\n', '.', $keywords);
>> $keywords = eregi_replace('\r', '.', $keywords);
>> $keywords = eregi_replace('\n\r', '.', $keywords);
>> $keywords = eregi_replace('<br>', '.', $keywords);
>>
>> any help here?
>
> 1) str_replace is more than capable of doing this in a single
> statement - a regex is overkill.
>
> 2) You need to use double quotes around escape sequences (\n and \r)
> or they'll be ignored.
>
> $replacements = array("\r", "\n", "\n\r", '<br>');
> $keywords = str_replace($replacements, '.', $keywords);
>
> -Stut
>

works like a charm!
:D

thanks stut!

-afan

-- 
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