Avoiding typing html tags, pros and cons
<p>Typing html is so boring and takes too much space and reduces code readability. What if to build such a function, and write all html with tag function. I know that just html is faster, but if to write html via tag function, how it will effect on site performance and page load time. General, is not bad to render html such a way? Thanks a lot. </p>

<pre><code>&lt;?php 
function tag($elem, $attr, $emb_elem = array()){
   $arr = explode("|", $attr);
   $attr_key = explode(',' , $arr[0]);
   $attr_val = explode(',', $arr[1]);
   $html = "&lt;" . $elem;
   for($i=0; $i&lt;count($attr_key); $i++){
      $html .= " " . $attr_key[$i] . "='". $attr_val[$i] . "'";
   }
   $html .= "&gt;";
   for($i=0; $i&lt;count($emb_elem); $i++){
      $html .= $emb_elem[$i];
   }
   $html .="&lt;/" . $elem . "&gt;";
   return $html;
}

echo tag("p", "class,id|someclass,someid", array("some data"));
# output: &lt;p class='someclass' id='someid'&gt;some data&lt;/p&gt;
</code></pre>
