Skip to content

Instantly share code, notes, and snippets.

@olimortimer
Created May 29, 2012 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olimortimer/2825946 to your computer and use it in GitHub Desktop.
Save olimortimer/2825946 to your computer and use it in GitHub Desktop.
PHP: Serialize Check
<?php
// There's no built in function to check if data is serialized or not
// other than trying to unserialize it, and receiving an error if it isn't...
function is_serialized($data){
if(trim($data) == "") {
return false;
}
if(preg_match("/^(i|s|a|o|d)(.*);/si",$data)) {
return true;
}
return false;
}
if(is_serialized($data))
$undata = unserialize($data);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment