public static function add_attributes($tag, $attributes) {
        $tag = self::remove_attributes($tag, array_keys($attributes));
        if (!preg_match('/^(<.*?)(>.*)$/s', $tag, $matches)) {
            return $tag;
        }
        $rv = $matches[1];
        foreach ($attributes as $name => $value) {
            $rv .= " $name=\"".s($value).'"';
        }
        $rv .= $matches[2];
        return $rv;
    }
public static function add_attributes($tag, $attributes) {
        $tag = self::remove_attributes($tag, array_keys($attributes));
        if (!preg_match('/^(<.*?)(>.*)$/s', $tag, $matches)) {
            return $tag;
        }
        $rv = $matches[1];
        foreach ($attributes as $name => $value) {
            $rv .= " $name=\"".s($value).'"';
        }
        $rv .= $matches[2];
        return $rv;
    }
public static function add_attributes ( $ tag , $ attributes ) { $ tag = self :: remove_attributes ( $ tag , array_keys ( $ attributes ) ) ; if ( ! preg_match ( '/^(<.*?)(>.*)$/s' , $ tag , $ matches ) ) { return $ tag ; } $ rv = $ matches [ 1 ] ; foreach ( $ attributes as $ name => $ value ) { $ rv .= " $name=\"" . s ( $ value ) . '"' ; } $ rv .= $ matches [ 2 ] ; return $ rv ; }
Adds attributes to the media tags

@param string $tag html tag which properties are extracted, for example "<video ...>....</video>"
@param array $attributes key-value pairs of attributes to be added
@return string
Adds attributes to the media tags