5 * Plugin to convert an associative array to a string of tag attributes.
9 * @author Paul M. Jones <pmjones@ciaweb.net>
11 * @license http://www.gnu.org/copyleft/lesser.html LGPL
13 * @version $Id: Savant3_Plugin_htmlAttribs.php,v 1.3 2005/09/12 17:49:27 pmjones Exp $
19 * Plugin to convert an associative array to a string of tag attributes.
23 * @author Paul M. Jones <pmjones@ciaweb.net>
27 class Savant3_Plugin_htmlAttribs
extends Savant3_Plugin
{
31 * Converts an associative array to a string of tag attributes.
35 * @param array $attribs
36 * From this array, each key-value pair is
37 * converted to an attribute name and value.
39 * @return string The XHTML for the attributes.
42 public function htmlAttribs($attribs) {
44 foreach ( ( array ) $attribs as $key => $val ) {
50 if (is_array ( $val )) {
51 $val = implode ( ' ', $val );
54 $key = htmlspecialchars ( $key );
55 $val = htmlspecialchars ( $val );
57 $xhtml .= " $key=\"$val\"";