3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = 'Other text1 {r|url-slug1|LinkTitle1} Other text2 {t|url-slug2|LinkTitle2} Other text3'; $pattern = '~ (?<before> .*? ) { (?: r (*MARK:ref) | t (*MARK:type) ) \Q|\E (?<url_slug> [^|]+ ) \Q|\E (?<linkTitle> [^}]+ ) } | (?<after> .+ ) ~xs'; preg_match_all($pattern, $s, $matches, PREG_SET_ORDER); $res = array_reduce($matches, fn($c, $i) => $c . ( $i['after'] ?? $i['before'] . '<a href="/' . $i['MARK'] . '/' . $i['url_slug']. '">' . $i['linkTitle'] . '</a>' ) ); echo $res;
Output for git.master, git.master_jit, rfc.property-hooks
Other text1 <a href="/ref/url-slug1">LinkTitle1</a> Other text2 <a href="/type/url-slug2">LinkTitle2</a> Other text3

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:
51.66 ms | 1390 KiB | 4 Q