How to display values from user input array?

Hi all,

I wrote a script that reads inputs from user and store in array named "input". The number of elements in the array is not fixed - determined only after user exit the while loop that reads the array values :

x=1
echo "Enter first value"
read input[$x]

while [ ${input[$x]} != "exit" ]
do
x=$((x + 1))
echo "Another value? (type exit to end) "
read input[$x]
done

Then I would like to print each of the array contents from input[1] until user exits. How can I do that?

Using for i in $input does not work for me.. please guide :o

A quick google search for bash array variables:

$ read input[1]
123
$ echo ${input[1]}
$ x=1
$ echo ${input[$x]}
123
$ read input[2]
456
$ x=2
$ echo ${input[$x]}
456