This gist has been deprecated and moved to a repository
(PHP 5 >= 5.4)
html_build_attributes β Generate a string of HTML attributes.
string html_build_attributes( array $attr [, callable $callback = null ] )Generate a string of HTML attributes from the associative array provided.
attrβ Associative array, or object containing properties, representing attribute names and values.
Ifattris an object, then only public properties will be incorporated into the result.
If a value is an array, its values will be concatenated and delimited with a space.
Values that cannot be converted into strings will be ignored. If the value is Stringable, Arrayble, or aClosure, attempts will be made to parse as a string.callbackβ Callback function for escaping the values for the HTML attributes.
If no sanitizer is provided,htmlspecialchars()is used;
If using WordPress, theesc_attr()function is used.
Returns a string of HTML attributes.
$ composer require mcaskill/php-html-build-attributes
Why are you not using composer? Download Function.HTML-Build-Attributes.php from the gist and save the file into your project path somewhere.