3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tagify($str, $baseUrl = '/board/') { $regExp = '/ (?!<a[^<>]*>[^\#]*) # Dont match if there is an opening link tag and any chars after it. \#([-_\w]+\b) # Match the hashtag. (?![^<]*<\/a>) # Ignore any closing link tag including any chars before it not in hashtag. /ix'; $baseUrl = rtrim($baseUrl, '/'); return preg_replace($regExp, '<a href="'.$baseUrl.'/$1">#$1</a>', $str); } $str = <<<STR This is <a href="http://foo.com">This is #foo</a>. Simple #html-stuff text <a href="http://foobar.com#baz">#simple</a> <span class="simple">simple #simple text text</span> STR; echo tagify($str);
Output for git.master, git.master_jit, rfc.property-hooks
This is <a href="http://foo.com">This is #foo</a>. Simple <a href="/board/html-stuff">#html-stuff</a> text <a href="http://foobar.com#baz">#simple</a> <span class="simple">simple <a href="/board/simple">#simple</a> text text</span>

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