I'm using the below for making the urls into hyperlinks but it messes up if there is not a white space at the end of the url is there a way so i can say if there is a white space an an '<'
$pmsg = preg_replace("~(http://|www)\S*~", "<a href=\"\0\" target=\"_blank\">\0</a>",$pmsg);