Here when I don't use unset()
function and print_r($color)
, it outputs YELLOW
as a result. I don't get why it outputs only YELLOW
?
$colors = array('red', 'blue', 'green', 'yellow');
foreach ($colors as $color) {
$color = strtoupper($color);
}
unset($color);
print_r($colors); // outputs: Array ( [0] => RED [1] => BLUE [2] => GREEN [3] => YELLOW )