Browse Source

add bio format method

main
ghost 3 years ago
parent
commit
5bb1e5ceb7
  1. 16
      src/system/helper/format.php

16
src/system/helper/format.php

@ -45,6 +45,22 @@ class Format {
} }
} }
public static function bio(string $string) {
$string = preg_replace("|([\s])\*([\S]+)\*([\s]?)|i", "$1<b>$2</b>$3", $string);
$string = preg_replace("|([\s])\~([\S]+)\~([\s]?)|i", "$1<i>$2</i>$3", $string);
$string = preg_replace("|([\s])\_([\S]+)\_([\s]?)|i", "$1<u>$2</u>$3", $string);
$string = preg_replace("|([\s])\-([\S]+)\-([\s]?)|i", "$1<s>$2</s>$3", $string);
$string = preg_replace("|([\s])\`([\S]+)\`([\s]?)|i", "$1<samp>$2</samp>$3", $string);
$string = preg_replace("|@([a-zA-Z0-9_]+)|i", "<a href=\"people/$1\">@$1</a>", $string);
$string = preg_replace("|((https?://)+([\d\w\.-]+\.[\w\.]{2,6})[^\s\]\[\<\>]*/?)|i", "<a href=\"$1\" target=\"_blank\">$3</a>", $string);
$string = nl2br($string);
return $string;
}
public static function post(string $string) { public static function post(string $string) {
$string = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');

Loading…
Cancel
Save