You can have multiple inputs in a loop. That's what it's designed for. It doesn't matter if the input is a fixed string, a variable, or a command substitution. The shell expands everything on the line before running the main command.
Code:
for ip in "$ip1" "$ip2"; do
ping $ip
done
The loop just takes everything after the word "in", does word splitting on them, places each "word" it finds in the first variable one at a time and processes the subsequent commands.
Note that this can cause problems if a variable contains spaces. Use quotes around anything that needs to be grouped together as a single unit.
Here are a few useful bash scripting references.
I highly recommend the first one for shell beginners:
http://www.linuxcommand.org/index.php
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/index.html
http://www.gnu.org/software/bash/manual/bashref.html