gotornot Posted October 13, 2009 Share Posted October 13, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/177542-turning-an-array-into-a-string-then-poping-it-into-a-db/ Share on other sites More sharing options...
mikesta707 Posted October 13, 2009 Share Posted October 13, 2009 look into serialize() Quote Link to comment https://forums.phpfreaks.com/topic/177542-turning-an-array-into-a-string-then-poping-it-into-a-db/#findComment-936130 Share on other sites More sharing options...
gotornot Posted October 13, 2009 Author Share Posted October 13, 2009 that really doesnt help... Quote Link to comment https://forums.phpfreaks.com/topic/177542-turning-an-array-into-a-string-then-poping-it-into-a-db/#findComment-936180 Share on other sites More sharing options...
mikesta707 Posted October 13, 2009 Share Posted October 13, 2009 ... 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 Quote Link to comment https://forums.phpfreaks.com/topic/177542-turning-an-array-into-a-string-then-poping-it-into-a-db/#findComment-936182 Share on other sites More sharing options...
ILMV Posted October 13, 2009 Share Posted October 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/177542-turning-an-array-into-a-string-then-poping-it-into-a-db/#findComment-936185 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.