Boolean/Integer Array Question

Hello, I hope my English is good enough so that you understand my question.
Basically, I have a Boolean Array with a fixed content. Is there a way to make an Integer Array out of the containing index elements that are set to true? For example, if the Index # 0, 7 and 24 are set to True, then my Integer Array would have only three elements with the values matching (0,7,24).
Hope it is possible and thanks in advance for your help.

int] array
for (int i = 0; i < boolarray.len(); I++)
ā€‹ā€‹ā€‹ if (boolarray*)
array.add(i)

Trying my best to make sense out of that but Iā€™m not doing it in C++ (not a programmer unfortunately). Thanks for the hint.

Basically use a for loop to go from 0 - last index of the bool array, and if it is true, add the index to the int array

Yep, it was that simple. Thanks a lot!