Join optgroup array dynamically