我正在尝试向序列化字符串添加数据-
我从数据库中获取序列化字符串,例如a:1:{I:0;s:2:“32”}取消序列化ITA向其添加值,例如128将其序列化并保存回
但我得到s:33:“a:2:{I:0;s:2:64;I:1;s:3:128”}”;
s:33是从哪里来的,用引号将其余的括起来,并以分号结尾?
function addItem($serializedArray, $item)
{
$a = unserialize($serializedArray);
$a[] = $item;
return serialize($a);
}
$lp = $wpdb->get_results( $wpdb->prepare("Select MemNo from YP_Members Limit 0, 10") );
foreach ($lp as $userid){
$user_id = $userid->MemNo;
$meta_value = $wpdb->get_var( $wpdb->prepare("Select meta_value from iropiusermeta Where meta_key = \'user_iro_area\' AND user_id = $user_id") );
echo "User=".$user_id."<br />Value=".$meta_value."<br />";
if ($meta_value){
$user_iro_area = addItem($meta_value, "128");
update_user_meta($user_id, \'user_iro_area_new\', $user_iro_area);
} else {
// Add meta_key user_iro_area
echo "<b>Add New Me</b><br />";
$iro_group_num[] = "128";
$user_iro_area = serialize($iro_group_num);
update_user_meta($user_id, \'user_iro_area_new\', $user_iro_area);
}
} // End of Main While Loop