I'm trying to query a serialized array value in the database in wordpress, value will be stored in the table wp_postmeta, in the column meta_value.
Well, first I stored the array by using serialize() function of php.
So for example,
$postID = 1;
$arr = array(1, 2, 3);
$ser_val = serialize($arr);
update_meta_data($postID, '_customvalue', $ser_val);
The stored values is something like this
s:30:"a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}";
Then when I tried to retrieve it by performing wordpress sql query.. What I was expecting that it will be an array since it is stored as array, but after doing so, it display as string not an array.
$get_score = $wpdb->get_row("SELECT meta_value FROM wp_postmeta WHERE meta_key = '_cummulativescore'");
$scr = unserialize($get_score->meta_value);
var_dump($scr);
//output displayed
//string(30) "a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}"
I did check the value using is_array() function, the result is that it is not an array
Any idea on this to get the serialize value as an array?