This is going to sound odd, but is there a way to dynamically create a class structure, or at least the class variables at runtime?

Basically what's happening is I'm taking in a mbox formatted string, and I would like to build a class that has variables as the same names as the headers (with two names of my own for the first line of a new message, and the body). But for instance, perhaps a message my have some extra X- headers, and some may not contain these.

I've tried doing things with a multi-dimensional array, but the sorting issue became a problem. And I'm thinking from what I've done so far, that the class route would be easier to code, and probably more efficient. But that's assuming I would some how be able to dynamically create class variables.