jbowman99
3 years ago

Returning array of flags

Posted 3 years ago by jbowman99

I have a Job model, this model has 11 boolean flags on it, each representing a different Boost. These can be turned on or off by an admin. I want to pass the $job to a function boostify($job) and return an array of the boosts that are turned on. I would like to make this simple, and not a bloated if else statement if possible.

My initial pass at it would be to, if check each boolean, if turned on plug into an array with an set index. boost 1 is on boost 2 is off and so on. This array in turn will be passed back to the calling function and for each flag that is on, an XML element will be created.

Thoughts on simplifying this?

Please sign in or create an account to participate in this conversation.