Here's the code:
<?php
function changeCase($string, $allupper = false)
{
$action = (false === $allupper) ? 'ucfirst' : strtoupper;
return $action($string);
}
$fruits = array(0 => 'orange', 1 => 'apple', 2 => 'pear');
foreach ($fruits as $key => $value) {
$fruits[$key] = changeCase($value, true);
}
print_r($fruits);
?>
What function would replace the foreach loop??? ...Notice the second argument to changeCase function.