Bash

Working with arrays:

#---- Create arrays ----#
# Declare 'foo' as array
# Accepts whitespace in string
declare -a foo=("one" "two" "three 3")
 
# ... or even as empty array
foo=()
foo+=("one")
foo+=("two")
 
#---- Iterate array ----#
# Iterate by element
# See 'https://stackoverflow.com/a/8880633' for why enclosing quotes
for elem in "${foo[@]}"; do
    echo $elem
done
 
# Iterate by index
len=${#array[@]}
for (( i=0; i<$len; i++ )); do
    echo "$i : ${array[$i]}"
done