PHP Create HTML Tag-Node
/**
* Generates an HTML Node
* @param string $name
* @param boolean $short
* @param array $attributes
* @param string $content
* @return Ambigous <NULL, string>
*/
function createTag($name, $short = false, $attributes = null, $content = null) {
$tag = null;
if (!$short) {
$tag = sprintf("<%s%s>%s</%s>", $name, array_to_html_attributes("=", $attributes), $content, $name);
} else {
$tag = sprintf("<%s%s/>", $name, array_to_html_attributes("=", $attributes));
}
unset($name, $short, $attributes, $content);
return $tag;
}
see for array_to_html_attributes: http://blog.teknober.com/2011/04/13/php-array-to-html-attributes/
| Print article | This entry was posted by editor on April 13, 2011 at 10:11 PM, and is filed under Development. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.


LinkedIn
Twitter
Skype