3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "<p>Just a test: getName testName</p>"; $keywords = [ 0=>['id'=>1,'slug'=>'getName','url'=>'https://www.getname.com'], 1=>['id'=>2,'slug'=>'testName','url'=>'https://www.testname.com'], 2=>['id'=>3,'slug'=>'ign','url'=>'https://www.ign.com'] ]; $newKeywords = []; foreach ($keywords as $keyword) $newKeywords[$keyword['slug']] = $keyword['url']; $newStr = preg_replace_callback("/(\w+)/", function($m) use($newKeywords){ return isset($newKeywords[$m[0]]) ? "<a href='{$newKeywords[$m[0]]}'>{$m[0]}</a>" : $m[0]; }, $str); echo $newStr;
Output for git.master, git.master_jit, rfc.property-hooks
<p>Just a test: <a href='https://www.getname.com'>getName</a> <a href='https://www.testname.com'>testName</a></p>

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