3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertHashtags($str) { $regex = '/@([a-zA-Z0-9]+[\sa-zA-Z0-9]*)/'; if(preg_match($regex,$str,$matches) === 1){ list($username,$name) = [$str , strtolower(str_replace(' ','',$matches[1]))]; return "<a href='profile?id=$name'>$username</a>"; } throw new Exception('Unable to find username in the given string'); } $string = 'I am @Marie Lee, nice to meet you!'; $string = convertHashtags($string); echo $string;
Output for git.master, git.master_jit, rfc.property-hooks
<a href='profile?id=marielee'>I am @Marie Lee, nice to meet you!</a>

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