开发者

What's the trick to display a text from MySql/PHP back to its original HTML layout?

It still keeps the orig开发者_JAVA百科inal text layout (I mean the spacing, offsets, new line, paragraphs) while the text fragment is stored in MySql ('text' type) field - I can tell when I peer into it in my DB browser (Adminer:) but it gets lost when I output it from the DB: it becomes a single line string of my text characters. How can one restore it its original layout? I've tried to reshape the text fragment using the PHP nl2br() function with some success: it brought back the newline breaks, but the text words positioning is not kept, everything shifts to the left. Thanks in advance for a good idea.


If you've got multiple spaces and things like that. e.g. for code. Then trying using the pre tag.

http://htmldog.com/reference/htmltags/pre

http://reference.sitepoint.com/html/pre


The html_entity_decode() function converts HTML entities to characters.

The syntax is:

html_entity_decode(string, [quotestyle], [character-set]);

You can refer example2.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜