Код: Выделить всё
Hello World!
Код: Выделить всё
$html = 'Hello World!';
$htmlDOM = new DOMDocument();
$htmlDOM->loadHTML( $html );
$xpath = new DOMXPath( $htmlDOM );
$headers = $xpath->query( '//h1//span|//h2//span|//h3//span|//h4//span|//h5//span|//h6//span' );
foreach( $headers as $index => $element ) {
print_r( $element ); // The Header Element
if( $element->attributes->length ) {
foreach( $element->attributes as $asdf => $attr ) {
print_r( $attr ); // The Span Attributes ( style )
}
}
}
< /code>
Я получаю атрибут фактического стиля с приведенным выше, но я не знаю, как назначить его родителю. Я не уверен, что это быстрее, чем preg_match () Подробнее здесь: https://stackoverflow.com/questions/383 ... und-colors
Мобильная версия