PHP unserialize function is use to convert an array string to an array.
But if the string not in proper array string it will return Notice error like below:
Notice: unserialize() [function.unserialize]: Error at offset 0 of 6 bytes
The easy way to fix this problem is write a function and call it “is_serialized”, use to check the string before unserialize it.
Below we show you how to use this function.
is_serialized function:
function is_serialized($str) { return ($str == serialize(false) || @unserialize($str) !== false); }
How to use:
if (is_serialized($string)) { print_r(unserialize($string)); }