HtmlUtil
in package
Table of Contents
Methods
- generateAttributeString() : string
- Generate a attribute string for html elements out of an array.
- generateDataAttributesString() : string
- Generates a data-attributes string out of an array.
Methods
generateAttributeString()
Generate a attribute string for html elements out of an array.
public
generateAttributeString(array<string|int, mixed> $attributes[, array<string|int, mixed> $options = [] ]) : string
Options:
- xhtml: (bool) XHTML format instead of HTML5 format. Default false
Parameters
- $attributes : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Return values
stringgenerateDataAttributesString()
Generates a data-attributes string out of an array.
public
generateDataAttributesString(array<string|int, mixed> $attributes[, array{xhtml?: bool, normalizeKeys?: bool, array_handling?: "reduce"|"encode"}|GenerateDataAttributesStringOptions $options = [] ]) : string
Parameters
- $attributes : array<string|int, mixed>
- $options : array{xhtml?: bool, normalizeKeys?: bool, array_handling?: "reduce"|"encode"}|GenerateDataAttributesStringOptions = []
-
(GenerateDataAttributesStringOptions is only supported from php 8.1)
Options (additional to Options from HtmlUtl::generateAttributeString()):
- normalizeKeys: Array keys are normalized to lowercase dash-cased strings (e.g. Foo Bar_player is transformed to foo-bar-player)