3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Rtm = '@[ Test Career 12](career:235)@[ Testing11](business:2)@[ Username](user:1)some text'; $Rtm = preg_replace_callback('/@\[([^]]*)\]\(([a-z]+):([^)]*)\)/', function ($match) { switch($match[2]) { case 'user': return "<a href=\"/en/main/profile_page_link/$match[3]\">$match[1]</a>"; break; case 'business': return "<a href=\"/en/business/1/about\">$match[1]</a>"; break; case 'career': return "<a href=\"/en/main/2/about\">$match[1]</a>"; break; default: return ""; break; } }, $Rtm); echo $Rtm;
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
<a href="/en/main/2/about"> Test Career 12</a><a href="/en/business/1/about"> Testing11</a><a href="/en/main/profile_page_link/1"> Username</a>some text

preferences:
75.98 ms | 407 KiB | 5 Q