Never been to DZone Snippets before?

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

Maybe UnSerialize (See related posts)

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 Wordpress 2.0 source. Yayyy for Open Source!

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

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts