A few more points:
- Comparing $input_city with $myCities will always fail (Unless someone typed the entire city list). You probably intended to compare with $city
- With your current code, every failed comparison will print the "I'm sorry" message. That should only print if ALL comparisons fail (as in after the for loop.)
- As pointed out earlier, "==" is for numeric comparison. Try "eq".
- The uc and lc functions can be used to make the comparisons case insensitive (or you could use a regular expression).
If you have studied hashes
, using that construct would make your code considerably simpler, and easier to read.
"As you get older three things happen. The first is your memory goes, and I can't remember the other two... "
- Sir Norman Wisdom