テキストからリンクを抽出

テキストからリンクを抽出し、リンクとして表示する方法

<?php
	$strText = 'yahooは http://www.yahoo.co.jp です';  
	$strText = preg_replace( '/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '<a href="\0">\4</a>', $strText );  
	echo $strText;  
?>  

あたらしい画面に表示したければ

<?php
	$strText = 'yahooは http://www.yahoo.co.jp です';  
	$strText = preg_replace( '/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '<a href="\0" target="_blank">\4</a>', $strText );  
	echo $strText;  
?>