Код: Выделить всё
$pattern = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$urls = array();
preg_match($pattern, $comment, $urls);
return $urls;
http://regexr.com?35nf9
Я вывожу массив $links, используя:
Код: Выделить всё
$linkItems = $model->getLinksInComment($model->comments);
// die(print_r($linkItems));
echo '[list]';
foreach ($linkItems as $link) {
echo '[*]' . $link . '';
}
echo '[/list]';
- http://google.com
- http
Код: Выделить всё
destined for surplus
RT#83015
RT#83617
http://google.com
https://google.com
non-link
Мобильная версия