$nomiarray=array("alias","pinco");

foreach($nomiarray as $nome):
foreach($$nome[$subMenu[$gallery]] as $k => $v):

eccetera...