Highway to PSR2
[openemr.git] / portal / patient / fwk / libs / savant / Savant3 / resources / Savant3_Plugin_htmlAttribs.php
blob104d6ed687e429febee3ef7d54e04c8f59f91c1e
1 <?php
3 /**
5 * Plugin to convert an associative array to a string of tag attributes.
7 * @package Savant3
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 $
17 /**
19 * Plugin to convert an associative array to a string of tag attributes.
21 * @package Savant3
23 * @author Paul M. Jones <pmjones@ciaweb.net>
27 class Savant3_Plugin_htmlAttribs extends Savant3_Plugin
30 /**
32 * Converts an associative array to a string of tag attributes.
34 * @access public
36 * @param array $attribs
37 * From this array, each key-value pair is
38 * converted to an attribute name and value.
40 * @return string The XHTML for the attributes.
43 public function htmlAttribs($attribs)
45 $xhtml = '';
46 foreach (( array ) $attribs as $key => $val) {
47 if ($val === null) {
48 continue;
51 if (is_array($val)) {
52 $val = implode(' ', $val);
55 $key = htmlspecialchars($key);
56 $val = htmlspecialchars($val);
58 $xhtml .= " $key=\"$val\"";
61 return $xhtml;