Making an active link in PHP -
i've created blog site php. there's section can make comment. wondering how make url active when post 1 in comment. i've noticed when make comment url in it, link not active or can't hover on it. there code make active?
you need convert part of string url link.
// regular expression filter $reg_exurl = "/(http|https|ftp|ftps)\:\/\/[a-za-z0-9\-\.]+\.[a-za-z]{2,3}(\/\s*)?/"; // text want filter urls $text = "the text want filter goes here. http://google.com"; // check if there url in text if(preg_match($reg_exurl, $text, $url)) { // make urls hyper links echo preg_replace($reg_exurl, "<a href="{$url[0]}">{$url[0]}</a> ", $text); } else { // if no urls in text return text echo $text; }
Comments
Post a Comment