<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chris Page - Software Engineer &#187; html</title>
	<atom:link href="http://www.chriswpage.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chriswpage.com</link>
	<description>... and student of Life, Philosophy, and Learning</description>
	<lastBuildDate>Sat, 17 Jul 2010 02:46:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generate any HTML tag with these two functions.</title>
		<link>http://www.chriswpage.com/2008/04/generate-any-html-tag-with-these-two-functions/</link>
		<comments>http://www.chriswpage.com/2008/04/generate-any-html-tag-with-these-two-functions/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 23:44:00 +0000</pubDate>
		<dc:creator>cpage</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.chriswpage.com/2008/04/generate-any-html-tag-with-these-two-functions/</guid>
		<description><![CDATA[I was working on a form generation API on Typhoon PHP Framework today and came up with two wonderful functions for generating any HTML tag using PHP.
Here are the functions, enjoy!:

public static function tag($element, $attributes = array()) {
    $buffer = '&#60;' . $element;

    foreach($attributes as $key =&#62; $val) {
 [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a form generation API on <a href="http://typhoon.shockwavelabs.com">Typhoon PHP Framework</a> today and came up with two wonderful functions for generating any HTML tag using PHP.</p>
<p>Here are the functions, enjoy!:</p>
<pre>
public static function tag($element, $attributes = array()) {
    $buffer = '&lt;' . $element;

    foreach($attributes as $key =&gt; $val) {
        $buffer .= ' ' . $key . '="' . $val . '"';
    }
    $buffer .= '/&gt;';

    return $buffer;
}

public static function blocktag($element, $attributes = array()) {
    $content = $attributes['content'];
    unset($attributes['content']);

    $buffer = '&lt;' . $element;
    foreach($attributes as $key =&gt; $val) {
        $buffer .= ' ' . $key . '="' . $val . '"';
    }
    $buffer .= '&gt;';

    $buffer .= $content;
    $buffer .= '&lt;/' . $element . '&gt;';

    return $buffer;
}</pre>
<p>Currently I use these in conjunction with Smarty helpers to create consistent markup across a project I&#8217;m working on.  Any thoughts are appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chriswpage.com/2008/04/generate-any-html-tag-with-these-two-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
