How can I extract the HTTP from this text?
"Text: Here's 2 free bonuses. http://blablabla.blabla/blabla "
But the URL can also be another one.
Finally
After I have the array, which contains usually just one URL, how can I add it to the above text exactly at the same position? But with HTML tag <a>
The results should look something like this:
"Text: Here's 2 free bonuses.
<a href='http://blablabla.blabla/blabla'>http://blablabla.blabla/blabla</a> "
You can do that using regular expression, and more precisely preg_replace(). The matching expression can be something like :
Of course, you can refine it for more precise matching, but this should do the trick. If you want to play with regex, have a look at regexpal, it’s a great tool for testing. Then, you can perform the replace ($0 corresponds to the whole matched string :