Reputation: 15
when i use this code
$a=array ( 'Q1' => 'gravity', 'Q2' => 'm*a',);
print_r($a); output will be array
$a is an array
suppose array ( 'Q1' => 'gravity', 'Q2' => 'm*a', )
is stored in a table column
when retrieved this column values and stored in a variable then that variable is not an array
Upvotes: 0
Views: 54
Reputation: 389
You can store array in to database using this one
$a=array ( 'Q1' => 'gravity', 'Q2' => 'm*a',);
$arrstr=mysql_escape_string(serialize($a));
Retrived by this function
$array= unserialize();
Upvotes: 0
Reputation: 392
before you save in db try:
json_encode($a);
result is json string, You should save that string in database. Then when you get from db just json decode that string.
json_decode($string_from_database);
Upvotes: 1