บทความ > PHP

[PHP] Remove HTML tag except some tag from text string Turn Back

เมื่อ 2017-03-08 11:20:30

function remTag($text)

{

$text = strip_tags($text, '', <p>);  // Kill all except <p> tag

$text = preg_replace('#<p class="some">(.*?)</p>#', '', $text);  // Remove some element by class name

return preg_replace('/class=".*?"/', '', $text); // Remove class name

}

 

 

Turn Back

Automotive ดูทั้งหมด

IT Update ดูทั้งหมด