Parsing serialized Array (Wordpress)

php, wordpress

Solution

that is a serialized array, use unserialize()

$array = unserialize('a:1:{i:0;s:8:"Religion";}');
echo $array[0];

Problem

I'm using wordpress and one of my meta key values is stored like this: ``` a:1:{i:0;s:8:"Religion";} ``` I'm trying to figure out the easiest way in PHP to parse this so I can extract "Religion" or really any of the elements in a clean manner. Hope this makes sense - thanks!!! Loren

Original source