Posted By

mscribellito on 12/02/10


Tagged

php html tag generate


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

banago
vehler
alebenson


HTML Tag Generator


 / Published in: PHP
 

  1. /**
  2.  * Generate HTML Tag
  3.  *
  4.  * @param string tag
  5.  * @param string content
  6.  * @param array tag attributes - array('class' => 'active')
  7.  * @return string compiled HTML tag
  8.  */
  9. function tag($tag = '', $content = '', $atts = array()) {
  10. $str = '<' . $tag;
  11. foreach ($atts as $att => $value) {
  12. $str .= ' ' . $att . '="' . $value . '"';
  13. }
  14. $str .= '>' . $content . '</' . $tag . '>';
  15. return $str;
  16. }

Report this snippet  

You need to login to post a comment.