3v4l.org

run code in 300+ PHP versions simultaneously
<?php $desc = '<p> <span style="font-size:12pt;"><strong>Nappe bouton power Samsung Galaxy S6 Edge G925F</strong></span> <br> <span style="font-size:12pt;"><u><i title="bouton power">Nappe Bouton poweR, compatible Samsung Galaxy S6 Edge G925F.</i></u></span> </p>'; canLinkThisWordIn('bouton Power', $desc); function canLinkThisWordIn($word, $html){ $forbidenTagsArray = array('strong', 'a', 'b', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'); $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DOMXpath($dom); $wordTags = $xpath->query("//*[text()[contains(translate(., '".strtoupper($word)."', '".strtolower($word)."'), '".strtolower($word)."')]]"); foreach($wordTags as $wordTag){ if(checkTagAndParent($wordTag, $forbidenTagsArray)){ echo "\n".$wordTag->nodeName." == ".$wordTag->nodeValue; } } return false; } function checkTagAndParent($tag, $forbiden){ if(!in_array($tag->tagName, $forbiden)){ if($tag->parentNode){ $parentTags = array_filter(explode("/", preg_replace("/\[[^]]+\]/", "", $tag->getNodePath()))); foreach($parentTags as $parentTag){ if(in_array($parentTag, $forbiden)){ return false; } } } return true; } return false; }
Output for git.master, git.master_jit, rfc.property-hooks
i == Nappe Bouton poweR, compatible Samsung Galaxy S6 Edge G925F.

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:
61.83 ms | 401 KiB | 8 Q