次の状況:
$text = "This is some <span class='classname'>example</span> text i'm writing to
demonstrate the <span class='classname otherclass'>problem</span> of this.<br />";
preg_match_all("|<[^>/]*(classname)(.+)>(.*)</[^>]+>|U", $text, $matches, PREG_PATTERN_ORDER);
<span class='classname'>example</span>
あるフィールドに「 」があり、別の「例」にある配列($ matches)が必要です。しかし、ここで取得するのは、「」を含む1つのフィールドと<span class='classname'>example</span>
「クラス名」を含む1つのフィールドです。
もちろん、他の一致の値も含まれている必要があります。
どうすれば正しい値を取得できますか?