Re: transfer list in textarea to comma delimited string

From: Date: Fri, 02 May 2008 15:29:29 +0000
Subject: Re: transfer list in textarea to comma delimited string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-273805@lists.php.net to get a copy of this message
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 -- http://stut.net/

« previous php.general (#273805) next »