Reputation: 47
I am new in wordpress and I confuse how to solve this.
$redeem = array(
date('Ymd'),
$_POST['value']
);
if ($point && is_array($point)) {
$n = sizeof($point);
$point[$n] = $redeem;
}
update_user_meta(get_current_user_id(), 'value', $point);
} else {
update_user_meta(get_current_user_id(), 'value', $redeem );
}
This code work properly, it makes the data in my database become array. The problem is, how can I show the data from my database into my work page ?
a:3:{i:0;s:8:"20160421";i:1;s:3:"222";
This is the result of value in my database. I just want to show the value of "222".
Thanks
Upvotes: 0
Views: 48
Reputation: 7221
In WordPress, when you insert/update array data into user_meta or post_meta table, it will automatically saves data in serialized form, so you have to unserialize those data while fetching.
Below you can find simple conversation for array to serialized data and serialized data to array. You have to pass serialized data into unserialize
function to fetch 222
value.
$arr = array("name"=>"milap","language"=>"php","cms"=>"WordPress");
$sd = serialize($arr);
$res = unserialize($sd);
echo "<pre>";print_r($res);
The output of above code is,
Array
(
[name] => milap
[language] => php
[cms] => WordPress
)
Upvotes: 1