3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<a href="page1.html#num0035583725">name1</a> <a href="page30.html#num0035584494">othername</a> <a href="page55.html#num0035584859">word</a> <a href="page132.html#num0035585496">wordname</a> <a href="page133.html#num0035586039">datadata</a> <a href="page203.html#num0035586647">fsdfasfas</a>'; $doc = new DOMDocument('1.0', 'utf-8'); libxml_use_internal_errors(true); $doc->LoadHTML($string, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $links = $doc->getElementsByTagName('a'); foreach($links as $link){ if(strpos($link->nodeValue, 'name1') !== FALSE) { $href = $link->getAttribute('href'); preg_match('/#\K.+/', $href, $fragment); echo $fragment[0]; } }
Output for git.master, git.master_jit, rfc.property-hooks
num0035583725

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:
133.46 ms | 405 KiB | 5 Q