Over a million developers have joined DZone.

Maybe UnSerialize

DZone's Guide to

Maybe UnSerialize

· ·
Free Resource
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;
			return $original;

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}