$str = PReg_Replace ("/(http:\/\/[_|-|A-Za-z0-9|]+[.]+[A-Za-z]{2,4}[-_~%#&=?.a-z0-9\/]*)/",
"<a href=\"\\1\" target=\"_blank\">\\1</a>",
$str
);
$str = PReg_Replace ("/(ftp:\/\/[_|-|A-Za-z0-9|]+[.]+[A-Za-z]{2,4}[-_~%#&=?.a-z0-9\/]*)/",
"<a href=\"\\1\" target=\"_blank\">\\1</a>",
$str
);
$str = PReg_Replace ("/(\s)(www.[_|-|A-Za-z0-9|]+[.]+[A-Za-z]{2,4}[-_~%#&=?.a-z0-9\/]*)/",
"\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>",
$str
);
$str = PReg_Replace ("/(\s)(ftp.[_|-|A-Za-z0-9|]+[.]+[A-Za-z]{2,4}[-_~%#&=?.a-z0-9\/]*)/",
"\\1<a href=\"ftp://\\2\" target=\"_blank\">\\2</a>",
$str
);
$str = PReg_Replace ("/mailto:([_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4})/",
"<a href=\"mailto:\\1\">\\1</a>",
$str
);
popr. muzes vsechny ty prvni a druhy argumenty dat do pole a udelat do pres jeden preg_replace .. ale to si najdi v manualu