PHP如何将数据附加到序列化数组中

2022-01-22 00:00:00 append serialization php

If I have a serialized array... how can I append more values to it? Should I unserialize it first -> add data and then serialize it again?

解决方案

Yes.

function addItem($serializedArray, $item)
{
   $a = unserialize($serializedArray);
   $a[] = $item;
   return serialize($a);
}

相关文章