Re: Storing an array on a table?
| From: | Jordan Miller | Date: | Thu, 01 Sep 2005 15:07:47 +0000 |
| Subject: | Re: Storing an array on a table? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40190@lists.php.net to get a copy of this message | ||
if you just have a simple array with automatic numeric keys and text you could just implode the data to a string with a separator not found in your data:
$dataArray = array("hello", "goodbye", "etc.");
$storable = implode("||||", $dataArray);
// $storable becomes "hello||||goodbye||||etc."
//then, use explode to get the original array back again
$dataArray = explode("||||", $storable);
you could use a similar technique if you want to put the keys in as well, albeit slightly more complicated (e.g. use "||||" to separate each element in the array and "||" to separate each key from its value). Just find a divider you know your data will not contain, such as a pipe: "|".
This has worked well for me.
Jordan
On Sep 1, 2005, at 8:55 AM, Miguel Guirao wrote:
I want to store an array into a field on a MySQL table, Is it posible to save it? Maybe into a string field?