Skip to content

Instantly share code, notes, and snippets.

@madbonkey
Created November 17, 2011 19:58
Show Gist options
  • Save madbonkey/1374307 to your computer and use it in GitHub Desktop.
Save madbonkey/1374307 to your computer and use it in GitHub Desktop.
HTML Element function
<?php
if(!function_exists("html_element")) {
function html_element($element, $attributes, $innerHTML = false) {
if(empty($element) || empty($attribues) || !is_array($attributes))
return false;
$output = '<'.$element;
foreach($attribues as $attr => $val) {
if(empty($val))
$output .= ' '.$attr;
else
$output .= ' '.$attr.'="'.$val.'"';
}
$output .= '>';
if($innerHTML != false)
$output .= $innerHTML;
$output .= sprintf('</%s>', $element);
return $output;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment