Try this:
function news($newsarray) { 
   $str="<div>";
   foreach($newsarray as $value) 
   {
       $str.="<h3>{$value['title']}</h3>";
       $str.="<h4>{$value['content']}</h4>";
   }
   $str.='</div>';
return $str;
}
echo news($newsarray);
solved Wraping foreach loop into div doesnt work [duplicate]