$string = 'text <span style="color:#f09;">text</span>
<span class="data" data-url="http://www.google.com">google.com</span>
text <span class="data" data-url="http://www.yahoo.com">yahoo.com</span> text.';
私がやりたいことは、クラスdataを持つすべてのスパンからdata-urlを取得することです。したがって、次のように出力されます。
$string = 'text <span style="color:#f09;">text</span>
http://www.google.com text http://www.yahoo.com text.';
そして、残りのhtml タグをすべて削除したいと思います。
$string = strip_tags($string);
出力:
$string = 'text text http://www.google.com text http://www.yahoo.com text.';
誰かがこれを行う方法を教えてもらえますか?