Retrieve serialize value in the database wordpress


Staff member
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. <br>
Well, first I stored the array by using serialize() function of php. <br>
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


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-&gt;get_row("SELECT meta_value FROM wp_postmeta WHERE meta_key = '_cummulativescore'");
    $scr = unserialize($get_score-&gt;meta_value);

    //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 <br>
Any idea on this to get the serialize value as an array?