Attributes are merged with the existing root element's attributes.
If no unique root node can be determined, a wrapping tag is added with all the given attributes. The name of this
tag can be specified with $fallbackTagName.
public addAttributes ( string $html, array $attributes, string $fallbackTagName = 'div', array $exclusiveAttributes = null ) : string | ||
$html | string | The HTML code to augment |
$attributes | array | Attributes to be added to the root element in the format array(' |
$fallbackTagName | string | The root element tag name if one needs to be added |
$exclusiveAttributes | array | A list of lowercase(!) attribute names that should be exclusive to the root element. If the existing root element contains one of these a new root element is wrapped |
return | string |