Html::parseAttributes PHP Méthode

parseAttributes() static public méthode

Returns a space-delimited string with items of the $options array.
static public parseAttributes ( $options = [] ) : string
$options Array of options.
Résultat string Composed attributes.
    static function parseAttributes($options = array())
    {
        if (!is_string($options)) {
            $attributes = array();
            foreach ($options as $key => $value) {
                $attributes[] = Html::formatAttribute($key, $value);
            }
            $out = implode(' ', $attributes);
        } else {
            $out = $options;
        }
        return $out;
    }

Usage Example

Exemple #1
0
 /**
  * Creates a link element for CSS stylesheets.
  *
  * @since version 0.85
  *
  * @param $url       String   of javascript file to include
  * @param $options   Array    of HTML attributes.
  *
  * @return string CSS link tag
  **/
 static function css($url, $options = array())
 {
     if (!isset($options['media'])) {
         $options['media'] = 'screen';
     }
     return sprintf('<link rel="stylesheet" type="text/css" href="%s" %s>', $url, Html::parseAttributes($options));
 }
Html