Unserialize PHP value only if it was serialized

If its necessary to check is string we got is serialized array and unserialize it if its true - next  function will do this job: