$arr=array ("x"=>array (1,2,3),"y"=>5); $y=0; foreach ($arr as $x) if(is_array ($x)) foreach ($x as $value) $y+=$value; else $y*=$x; echo $y;