function array_to_attributes ( $array_attributes )
{
$attributes_str = NULL;
foreach ( $array_attributes as $attribute => $value )
{
$attributes_str .= " $attribute=\"$value\" ";
}
return $attributes_str;
}
$attributes = array(
'data-href' => 'http://example.com',
'data-width' => '300',
'data-height' => '250',
'data-type' => 'cover',
);
echo array_to_attributes($attributes) ;
↧
Answer by Softmixt for Fastest way to implode an associative array with keys
↧