/ * * @param string $text = the text for checking URLs/Links. * @return array $urls = 'is_url_exist' for true/false, 'urls'= list of found URLs * / static function is_url_exist_in_text($text="") { $urls = array(); $is_url_exist = false; / / $reg_exUrl = "/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)|(/[a-zA-Z\.]+\.[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/))?/"; $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; // for url format : http://example.com/demo | http://example.com preg_match($reg_exUrl, $text, $url_1); $reg_exUrl = "/(www)\.[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; // for url format : www.example.com | http://www.example.com preg_match($reg_exUrl, $text, $url_2); $urls = array_merge($url_1, $url_2); if(count($urls)>=1) { $is_url_exist = true; } $results = array('is_url_exist'=>$is_url_exist, 'urls'=>$urls); return $results; }
Friday, 17 December 2010
Filtering the URL in text, checking the links/URLs in text
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please post any queries and comments here.