I have a string like this into my page php:
$string = 'this is a test for @john and I can do all @mike';
I would like to take this string find all string inside it after @ and use it to find the name of the user with that user id if exist and convert into a link to become something like this:
$string = 'this is a test for <a href="/user?id=111">@john</a> and I can do all <a href="/user?id=112">@mike</a>';
How to take all string and use it to find the id of that user and after substitute the original string with a link?
I know that using preg_match I can take the string inside it but how to use this string? ando how construct this expression to take the name after @?
Thanks
preg_match_allto get all the@tokens then create an array of replacements usestr_replace