title: How do I map an associative array to html element attributes?
body: <p>I'm building a basic form building class to speed my workflow up a bit and I'd like to be able to take an array of attributes like so:</p>
  
  <pre><code>$attributes = array(
     "type"         =&gt; "text",
     "id"           =&gt; "contact-name",
     "name"         =&gt; "contact-name",
     "required"     =&gt; true
  );
  </code></pre>
  
  <p>and map that to the attributes of a html element:</p>
  
  <pre><code>&lt;input type="text" id="contact-name" name="contact-name" required /&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>What is the cleanest way of achieving the above? I'm sure I could cobble something together with a loop and some concatenation but I get the feeling printf or similar could do it in a more elegant manner.</p>