I am trying to create a script that will help me convert urls provided by users in their blog posts of PM to other users into a real clickable links , The script i created is working fine except that it is not converting after the 2nd link occurred in the post , I hope someone can help me with that.
Here is the code :
You’re accessing the wrong portion of the array returned by preg_match_all(). $link[0] contains the entire match, not the just the link you’re targeting with the regex subpattern. Loop through $link[1]. That has all the URL’s you want, already stripped of formatting. There’s no need to run two more regular expressions as well as the str_replace().
Also, your regex expression could be tidied up a bit.