I came across this some months ago so maybe my experience can help you.
It’s not that you can’t use a variable, but you can only use something that’s called an opaque type (https://www.opengl.org/wiki/Data_Type_(GLSL)#Opaque_types).
This means you can perfectly fine use uniforms. Depending on the way you implement your texture selection, you could use an int array to select the indices of your sampler array - does this work for you?
An alternative would be to use texture arrays. I finally did this because I got indices from a dynamic texture, so not opaque - but as mentioned by Riven, you there are limitations, for example all entries must have same size, format etc.
Maybe it’s ugly, but the if-else-thing would be possible too, of course. From my experience, there’s no speed penalty, but you would have a hardcoded max value for the index.