Ok, here are some more details.
The reason I want to use return within the foreach in the first place is that I'm using functions to generate menus. I dont want to use echos within this functions, I just want them to return the menus so that I can echo the function itself when needed:
function the_menu($condition){
$array = array('menu1','menu2','menu3');
foreach($array as $item){
if($item == $condition){
return $item.'_hilited';
} else {
return $item;
}
}
I would then like to use the_menu($condition) as a variable instead of executing it.
Example:
$the_menu = the_menu('menu2');
If I use echo statements within the function, the items are printed instead of being stored into my $the_menu variable.
So what would be the proper way to do this?