I am going to make an assumption that this is inside a clocked process (a little bit more info would be helpful).
When you run your for loop, the array index will always follow [i], so the result is:
array[20];
..
array[19];
..
..
array[0];
but with your index as temp, you end up with
temp = 20;
..
temp = 19;
..
..
temp = 0;
In this case, temp is assigned multiple times, therefore temp will get the lower assignment (temp = 0).
so you will end up with:
Array[20] = array[0];
...
Array[19] = array[0];
...
Array[0] = array[0];
If this isn't it, more information on the code would be helpful.