无法在php中取消序列化对象数组
我有一个在PHP中使用的Shift对象数组。我需要将这些对象存储在数据库中。我正在开发一个将向数据库添加班次的功能:无法在php中取消序列化对象数组,php,serialization,Php,Serialization,我有一个在PHP中使用的Shift对象数组。我需要将这些对象存储在数据库中。我正在开发一个将向数据库添加班次的功能: $Serialized_S = get_option('MasterShiftString'); $MasterShiftArray = unserialize($Serialized_S); if(!$MasterShiftArray) { echo "MasterShiftArray returns false"; }//end if echo "Serializ
$Serialized_S = get_option('MasterShiftString');
$MasterShiftArray = unserialize($Serialized_S);
if(!$MasterShiftArray)
{
echo "MasterShiftArray returns false";
}//end if
echo "Serialized_S:";
print_r($Serialized_S);
echo "<br />MasterShiftString:";
print_r($MasterShiftString);
echo "<br />end<br />";
if(!is_array($MasterShiftArray))
{
echo "MasterShiftArray is not an Array....";
$MasterShiftArray = array($last_monday_from_date => "");
}//end if
else
{
}//end else
$WeekShiftArray = $MasterShiftArray;
array_push($WeekShiftArray, $CurrentShift);
$MasterShiftArray[$last_monday_from_date] = $WeekShiftArray;
$Serialized_s = serialize($MasterShiftArray);
update_option('MasterShiftArray', $Serialized_s);
我做错了什么?我已经尝试过base64编码,但这没有任何帮助。
MasterShiftArray不是数组….这是:
admin,resource,2,1;admin,resource,2,1;admin,resource,2,1;admin,resource,2,1
看起来一点也不像PHP序列化数组,这是您的问题。垃圾输入=垃圾输出
假设这是您需要处理的数据格式,请研究如何将其分解为“;”上的数组,然后在“,”上分解该数组的每个成员。OMG。。。我很抱歉。。。。我现在觉得自己像个十足的白痴。。。我输入了错误的var。
admin,resource,2,1;admin,resource,2,1;admin,resource,2,1;admin,resource,2,1