Jyxo\Html::removeAttributes PHP Method

removeAttributes() public static method

If no attributes are given, the default set will be used. Expects valid HTML source.
public static removeAttributes ( string $html, array $attributes = [] ) : string
$html string HTML source code
$attributes array Attributes to be removed
return string
    public static function removeAttributes(string $html, array $attributes = []) : string
    {
        // Default set of attributes
        static $default = ['id', 'class'];
        // If no attributes are given, the default set will be used
        if (empty($attributes)) {
            $attributes = $default;
        }
        // Remove given attributes
        foreach ($attributes as $attribute) {
            $html = preg_replace('~(<[a-z][a-z0-9]*[^>]*?)\\s+' . $attribute . '="[^"]*"~is', '\\1', $html);
        }
        return $html;
    }