Detecting URL


How do I detect a url from a bunch of text?

I don’t want to turn the url into a link, I want to echo the link on its own.

For e.g

$text = ‘hello this is text

I would like to detect the url in the above text, and echo just the url.

Check out CakePHP’s implementation. :slight_smile:

Hi, I took a look at that code and it only shows how to convert the url into a link.

How do I use that to echo just the url?
(Sorry, I have a very basic knowledge of php)

I’m not a php guru myself, but when I need to work with strings I just Google for “php string functions” and than figure out how what i need can be done.
You basically will need to find a piece of text starting with www. and ending with a space, then use php StrReplace function.
I think using the basic string functions will be way easier than trying to find a ready-made solution for this task