How To Withdraw Specific Course Of Written Report In Addition To Attributes From Html Tags Using Php?
I recommend PHP Simple HTML DOM Parser, allow y'all manipulate HTML inwards a really slow way!. You tin respect tags on an HTML page amongst selectors only similar jQuery.
Sumber http://developer-paradize.blogspot.com
$html = "<div> <span class="test1 test2 test3" data-id="5" >text 1</span><br /> <span class="test1 test3 test2">text 4</span></div>";If only desire to either empty or take away whatever degree that has "test2" inwards it as well as take away attributes similar "data-id". You tin utilization PHP Simple HTML DOM Parser to take away specific degree as well as attribute from HTML tags similar below. In guild to delete specific degree from HTML tags, y'all tin utilization SIMPlE PHP DOM Parser as well as preg_replace function. You tin take away attributes easily using removeAttribute method.
// Find all elements amongst the degree test2 attribute foreach($html->find('[class=test2]') equally $e){ $e->removeAttribute("data-id"); //remove attribute $e->class = preg_replace("/(?:^|\s)editable(?:\s|$)/msi", " ", $e->class); } echo $html;The lawsuit
<div> <span class="test1 test3">text 1</span><br /> <span class="test1 test3">text 4</span></div>If y'all guys know whatever other efficient way, produce portion for our users. :)
Sumber http://developer-paradize.blogspot.com
Comments
Post a Comment