I need some help with unserializing and updating the array values and reserializing them (using php). Basically I want to be able to unserialize a string, update the value for a specific key (without loosing the other values) and reserialize it. I've searched and can't seem to find a viable solution (or maybe I'm just typhlotic).
The array I'm trying to update is very simple. It has a key and value.
array (
'key' => 'value',
'key2' => 'value2',
)
I currently have, but it does not work.
foreach(unserialize($serializedData) as $key => $val)
{
if($key == 'key')
{
$serializedData[$key] = 'newValue';
}
}
$updated_status = serialize($serializedData);
$serializedDataas this is the serialized representation of your array. Save the result of your call to unserialise() and use this instead. That should do the trick.$serializedData[$key]business.