我认为这几乎是不可能的。在修理阵列之前,您需要知道阵列是如何损坏的。有多少孩子失踪?内容是什么?
对不起,恕我直言,你做不到。
证明:
<?php$serialized = serialize( [ 'one' => 1, 'two' => 'nice', 'three' => 'will be damaged' ]);var_dump($serialized); // a:3:{s:3:"one";i:1;s:3:"two";s:4:"nice";s:5:"three";s:15:"will be damaged";}var_dump(unserialize('a:3:{s:3:"one";i:1;s:3:"two";s:4:"nice";s:5:"tee";s:15:"will be damaged";}')); // please note 'tee'var_dump(unserialize('a:3:{s:3:"one";i:1;s:3:"two";s:4:"nice";s:5:"three";s:')); // serialized string is truncated链接:https://ideone.com/uvISQu
即使可以重新计算键/值的长度,也不能信任从此源检索到的数据,因为您不能重新计算键/值的值。例如。如果序列化的数据是对象,那么您的属性将不再可用。



