Merge two arrays consisting of HTML attributes
html:merge_default_attributes(ARRAY $main_attributes, ARRAY $default_attributes=[ ]) : ARRAY
html:merge_default_attributes(['style' => 'color:red', 'id' => 'foo4'], ['style' => 'color: blue'])
section replace attributes {
html:merge_default_attributes(['style' => 'color:red', 'id' => 'foo4', 'remove_default_attributes?' => true], ['style' => 'color: blue','onclick' => 'alert(1)'])
#=> [ "style" => "color:red", "id" => "foo4" ]
}
section replace multiple attributes {
$b = 3
$a1 = [
'style' => 'color:red',
'id' => 'foo',
'replace_default_attributes?' => true
]
html:merge_default_attributes($a1, ['style' => 'color: blue'])
}
#=> [ "id" => "foo", "style" => "color:red" ]
html:merge_default_attributes(['style' => 'color:red', 'id' => 'foo4', 'replace_default_attributes?' => true], ['style' => 'color: blue','onclick' => 'alert(1)'])
#=> [ "id" => "foo4", "onclick" => "alert(1)", "style" => "color:red" ]
#===
#=> [ "style" => "color:red", "id" => "foo4" ]
Copyright ©2013-2022 SunSed®. All rights reserved.