<?php
function hyperlink($texto) {
	#Procura pelo protocolo http ou https://
	$texto = ereg_replace("[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*", "<a href=\"\\0\">\\0</a>", $texto);

	#Procura pelo dominio.extensao...
	$texto = ereg_replace("(^| )(www([.]?[a-zA-Z0-9_/-])*)", "\\1<a href=\"http://\\2\">\\2</a>", $texto);

	#Retorno
	return "$texto";
}

#Nosso texto...
$texto = "Entra ai http://www.phpbrasil.com e www.google.com";

#Usando a função...
$myvar = hyperlink($texto);
?>