Computing Magazine

Save an Array into Database Table

Posted on the 24 April 2012 by Akahgy

Description:

How to save an Array variable as a regular database value?

Solution:

PHP offers the serialize() function, that creates a representation of the variable that can be stored everywhere. This can be used for other types of variables as well, but it is most common for Array.

myqsl_query(“INSERT INTO table_name(column_name) VALUES(“.serialize($array_variable).”)”);

 

To return the value, we can use the unserialize() function, for the serialized object.


Back to Featured Articles on Logo Paperblog

Magazine