Jump to content

turning an array into a string then poping it into a db


gotornot

Recommended Posts

Hi im just wondering how you get a requested array into a single string then pop it into the db so far i got

print_r($_REQUEST['choice_name']);

 

whch echos

 

Array ( [0] => Colour=Blue [1] => Size=8 [2] => Neck Line=V )

 

I need it to look ready to enter into a db in a single field like this

 

Colour=Blue Size=8 Neck Line=V

 

Any ideas

... did you use it right.

 

this can store a textual representaion of an array (or any object), that can then be unserialized and turned back into the array. Unserializing objects is rather slow however, so be aware of that. alternatively, I suppose you could use json_encode/decode

Are you trying to store the array as a string, and then retrieve it at a later stage and then resotre it back to an array?

 

If so mikesta is correct, you should serialize() and unserialize() your string.

 

 

The reason I ask this is I find it hard to believe you can store useful information in the format you have specified, perhaps you could justify your requirements a bit more so we can offer an appropriate solution.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.