php格式化文本换行缩进

曾经针对文本的换行添加样式的简单方法,记一下笔记
1
2
3
4
5
6
7
8
public static function add_html_p($text){
$keyword_arr = explode("\n", $text);
$new_text = '';
foreach ($keyword_arr as $k => $v){
$new_text .= '<p style="text-indent:2em;margin: 0px;line-height:1.7">'.$v.'</p>';
}
return $new_text;
}