123456789101112 |
- <?php
- function text2html($text,$ifnoe) {
- if (is_null($text) || preg_match('#^\s*$#',$text)===1)
- return $ifnoe;
- $text=preg_replace(['#<#','#>#'],['<','>'],$text);
- $text=preg_replace('#(https?://.+?)(\s|$|\W\s|\W$)#m','<a href="$1" target="_blank">$1</a>$2',$text);
- $text=nl2br($text);
- return $text;
- }
- ?>
|