DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chris has posted 2 posts at DZone. View Full User Profile

Maybe UnSerialize

  • submit to reddit
        Checks to see if a string is actually the serialized version of an array. If it is, we return an unserialized version. If not, return the original string. This way, we can just call our function on stored DB values and not worry about checking the results.

This was snagged from the <a href="">Wordpress</a> 2.0 source. Yayyy for Open Source!

	function maybe_unserialize ( $original ) {
		if ( false !== $gm = @ unserialize($original) )
			return $gm;
			return $original;