public static addCssStyle ( array &$options, string | array $style, boolean $overwrite = true ) | ||
$options | array | the HTML options to be modified. |
$style | string | array | the new style string (e.g. `'width: 100px; height: 200px'`) or array (e.g. `['width' => '100px', 'height' => '200px']`). |
$overwrite | boolean | whether to overwrite existing CSS properties if the new style contain them too. |
public static function addCssStyle(&$options, $style, $overwrite = true)
{
if (!empty($options['style'])) {
$oldStyle = is_array($options['style']) ? $options['style'] : static::cssStyleToArray($options['style']);
$newStyle = is_array($style) ? $style : static::cssStyleToArray($style);
if (!$overwrite) {
foreach ($newStyle as $property => $value) {
if (isset($oldStyle[$property])) {
unset($newStyle[$property]);
}
}
}
$style = array_merge($oldStyle, $newStyle);
}
$options['style'] = is_array($style) ? static::cssStyleFromArray($style) : $style;
}