Re: splitting string

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

 



The problem is that you are using single quotes, so php is looking for a literal \n rather than escaping it to a new line character. Try double quotes and then PHP will parse the contents of the quotes, looking for escape characters and variables.
explode("\n")


Use nl2br() to convert new lines to <br />.

On Nov 16, 2004, at 1:01 PM, Afan Pasalic wrote:

I create a string from other strings:
$string = $string1."\n".$string2."\n".$string3."\n".$string4."\n".$string5;
and then store it in DB.


But, I can't figure out how to split them back?

Tried:
$string_back = explode('\n', $string);
$string_back = explode('<br>', $string);
$string_back = explode('<br />', $string);

Anu help?

Also, is there actially better way to do this then adding \n between strings?
(e.g. store form fields name, address, city, state, zip, phone, email as a one string in db and later pull them from DB and split them back?)


Thanks for any help!
-afan

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


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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