Echoing variable values as set or empty and serializing array