find and replace urls in text with anchor tags

Find a url in text and create a working anchor tag for it.

$text = preg_replace('((www|http:\\)[^ ]+)','\\0', $text);