<?
$msg_by_post = 'https://site.ru text text text http://site.net text text http://site.com text text text https://site.su text';
preg_match_all('/(((http(s)?):\/\/)site(.([ru|su|net|com]*)))/',$msg_by_post,$array_mg);
$c_p = count($array_mg[0])-1; $i=0;
while ($i <= $c_p):
$array_mg[$i] = $array_mg[0][$i].'<br>';
$array_all = $array_all.$array_mg[$i];
++$i; endwhile;
echo $array_all;
?>