PHP DOM: Parsen einer HTML-Liste in ein Array?

Ich möchte die HTML-Liste in ein Array verwandeln,

<code>$string = '
<a href="#" class="something">1</a>
<a href="#" class="something">2</a>
<a href="#" class="something">3</a>
<a href="#" class="something">4</a>
';
</code>

Ich arbeite an der DOM-Methode,

<code>$dom = new DOMDocument;
$dom->loadHTML($string);
foreach( $dom->getElementsByTagName('a') as $node)
{
    $array[] = $node->nodeValue; 
}

print_r($array);
</code>

Ergebnis,

<code>Array ( [0] => 1 [1] => 2 [2] => 2 [3] => 4)
</code>

aber ich suche das Ergebnis tatsächlich so,

<code>Array ( 
[0] => <a href="#" class="something">1</a>
[1] => <a href="#" class="something">2</a> 
[2] => <a href="#" class="something">3</a>
[3] => <a href="#" class="something">4</a>
)
</code>

ist es möglich?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage