function to build xhtml tag - Php

Tag Builder

Snippet Code


  
Rate this page :
  [ 0 votes]

<?php function build($tag, $att = array(), $selfColse = FALSE, $inner = ''){ $t = '<'.$tag.' '; foreach($att as $k => $v){ $t .= $k.'="'.$v.'"'; } if(!$selfColse) $t .= '>'; else $t .= ' />'; if(!$selfColse) $t .= $inner.'</'.$tag.'>'; return $t; } echo build('input', array('type'=>'text', 'value'=>'WOOT!'), TRUE); echo build('div', array('style'=>'border:solid 1px

Tags


Ask Questions

Ask Question