Created
April 27, 2018 13:37
-
-
Save cbwar/cc3a66098a0881334832355611f1371a to your computer and use it in GitHub Desktop.
Unserialize to specified class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function unserializeToClass($object, $class = 'stdClass') | |
{ | |
return unserialize(preg_replace('/^O:\d+:"[^"]++"/', 'O:' . strlen($class) . ':"' . $class . '"', $object)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment