3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<str <a href="https://www.domainurl.com/refer/google-adsense/">fsdf</a> <a title="Google Adsense" href="https://www.domainurl.com/refer/google-adsense/" target="_blank" rel="nofollow noopener">fgddf</a> <a href="https://www.domainurl.com/page/pago">domain </a> <a title="Google Adsense" href="https://www.googlead.com/refer/google-adsense/" target="_blank" rel="nofollow noopener">googled</a> str; $domainToRemove = 'domainurl.com'; $dom = new DOMDocument; $dom->loadHTML("<div>{$str}</div>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $anchors = $dom->getElementsByTagName('a'); // Code taken and modified from: http://php.net/manual/en/domnode.replacechild.php#50500 $i = $anchors->length - 1; while ($i > -1) { $anchor = $anchors->item($i); if (strpos($anchor->getAttribute('href'), $domainToRemove) !== false) { // $new = $dom->createElement('p', $anchor->textContent); $new = $dom->createTextNode($anchor->textContent); $anchor->parentNode->replaceChild($new, $anchor); } $i--; } // Create HTML string, then remove the wrapping div. $html = $dom->saveHTML(); $html = substr($html, 5, strlen($html) - 7 - 5); echo $html;
Output for git.master, git.master_jit, rfc.property-hooks
fsdf fgddf domain <a title="Google Adsense" href="https://www.googlead.com/refer/google-adsense/" target="_blank" rel="nofollow noopener">googled</a>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
29.33 ms | 405 KiB | 5 Q