3v4l.org

run code in 300+ PHP versions simultaneously
<?php libxml_use_internal_errors(true); // to disable warnings if HTML is not well formed $o = new DOMDocument(); $o->loadHTML('<a href="../plugins/re_records/somefile.php?page=something&id=45">important_name</a>'); foreach($o->getElementsByTagName('a') as $anchor_tag){ $href = $anchor_tag->getAttribute('href'); if(strpos($href,'/plugins/re_records/somefile.php?page=something&id=') !== false){ $anchor_tag->setAttribute('href','/map/'.$anchor_tag->nodeValue); } } echo $o->saveHTML();

preferences:
40.52 ms | 405 KiB | 5 Q