How to display the text entered by the user
This is a user input copied from a database. First of all, it is not rich text, but it should be displayed in a beautiful format (roast).
php
How to handle characters?
$intro_ arr=explode("\n",$str); // Split into arrays based on line breaks
$new_str = '';
foreach($intro_arr as $item) {
//Exclude white space characters
if(!empty($item)){
//Remove blank characters on both sides? The trim function cannot remove half width spaces.
$item = mb_ ereg_ replace('^( | )+','', $item);// Remove left margin
$item = mb_ ereg_ replace('( | )+$','', $item);// Remove right margin
//Set of labels,,
$item_p = '<p style="text-indent:2em;">'.trim($item).'</p>';
$new_str .= $item_p;
}
}
This work adoptsCC agreement, reprint must indicate the author and the link to this article