First commit
This commit is contained in:
parent
9def51b8ec
commit
09ac498c80
1 changed files with 12 additions and 0 deletions
12
web/lib/text2html.php
Normal file
12
web/lib/text2html.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
function text2html($text,$ifnoe) {
|
||||
if (is_null($text) || preg_match('#^\s*$#',$text)===1)
|
||||
return $ifnoe;
|
||||
$text=htmlspecialchars($text,ENT_QUOTES|ENT_HTML5,'UTF-8');
|
||||
$text=preg_replace('#(https?://.+?)(\n|\s|\W\s|\W\n)#','<a href="$1" target="_blank">$1</a>$2',$text);
|
||||
$text=nl2br($text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue