Regex kullanarak PHP etiketleri şerit nasıl?

0 Cevap php
$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.';

Ne yapmak istiyorum class data ile her karış gelen data-url olsun. Yani, çıkış yapmalıdır:

$string = 'text <span style="color:#f09;">text</span>
http://www.google.com text http://www.yahoo.com text.';

Ve sonra tüm geri kalan html tags kaldırmak istiyorum.

$string = strip_tags($string);

Çıktı:

$string = 'text text http://www.google.com text http://www.yahoo.com text.';

Birisi bu nasıl yapılabilir bana söyleyebilir misiniz?

0 Cevap