- var_dump: documentation ( source)
- preg_match: documentation ( source)
- unserialize: documentation ( source)
<?php
function sugar_unserialize($value)
{
preg_match('/[oc]:\d+:/i', $value, $matches);
if (count($matches)) {
return false;
}
return unserialize($value);
}
$test1 = 'O:8:"stdClass":0:{}';
$test2 = 'O:+8:"stdClass":0:{}';
var_dump(sugar_unserialize($test1), sugar_unserialize($test2));