How i can save an array into database as string
col1 | col2 ------------------- 1 | array(1,2) ------------------- 2 | array(6,9)
all value in the array related together
use serialize() and unserialize()
http://php.net/manual/en/function.serialize.php
http://php.net/manual/en/function.unserialize.php
Your data would look like this: a:2:{i:0;i:1;i:1;i:2;}
You can use either Serialize() and Unserialize() you can use the php defualt implode function
You can also use json_encode()
And when you are getting it back out of database u can convert it back to an array with json_decode()
You can use serialize() before you insert the array. And unserialize() to get the data back as php array.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.