Re: splitting string

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

 



On Wednesday 17 November 2004 02:01, 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);

Notice that you used "\n" when creating $string? Do the same here.

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

You're not using your database like it should be used. Each invidually 
identifiable item should be stored in a separate column. Lumping everything 
into one column makes it harder to extract and process data. Google for 
"normalise table tutorial", or "normalize table tutorial" if you want things 
from a mainly American point of view.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
You carve wounds upon my flesh and write there in salt!

  -- Fremen Lament
*/

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