I have an array of Shift objects that I'm working with in PHP. I need to store these objects within a database. I'm working on a function that will add shifts to the database:
$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);
Of course what I'm getting when I execute this is:
last_monday_from_date: 1260777600
MasterShiftArray returns falseSerialized_S:admin,resource,2,1;admin,resource,2,1;admin,resource,2,1;admin,resource,2,1;
MasterShiftString:
end
What am I doing wrong here? I've tried the base64 encoding, but that doesn't do anything to help. MasterShiftArray is not an Array....