My first thought here was: There should be a simpler way to do this. Probably you thought the same when you copied the code over here.

The ugly part is, the the option keys are different from the once in params (missing an _). But this code makes it really hard to add more options and not to forget about this code. We could simplify it by storing all "options" to a second array. But then we store the values twice which is also ugly. Any better idea?