At the completion of the foreach loop $color contains the last array element changed to upper case ie it contains "YELLOW". If you print out it's contents using print_r it will output "YELLOW" unless you have already unset it.
What was it you were trying to do? did you want to change each element of the array to upper case, if so you need to use the following foreach loop (note the addition of '&'):