【发布时间】:2016-06-03 23:11:32
【问题描述】:
如果我喜欢那个格式字符串,我如何用 PHP 把它变成一个格式良好的段落,比如 text-align: justify in CSS and full-width of browser window?
<?php
$text = "It is a long
established fact that a reader
will be distracted
by the readable content of a
page when looking at its layout.
The point of using Lorem Ipsum
is that it has a
more-or-less normal distribution of
letters, as opposed to using 'Content here,
content here', making it look like readable English.
Many desktop publishing packages and web
page editors now use Lorem Ipsum as their
default model text, and a search for 'lorem ipsum'
will uncover many web sites still in their infancy.
Various versions have evolved over the years,
sometimes by accident, sometimes on
purpose (injected humour and the like).
";
?>
结果我想把这一段变成这种格式:
一个由来已久的事实是,读者在查看页面布局时会被页面的可读内容分散注意力。使用 Lorem Ipsum 的关键在于它具有或多或少的正态分布字母,而不是使用“这里的内容,这里的内容”,使它看起来像可读的英语。许多桌面出版包和网页编辑器现在使用 Lorem Ipsum 作为他们的默认模型文本,搜索“lorem ipsum”将发现许多仍处于起步阶段的网站。多年来,各种版本不断演变,有时是偶然的,有时是故意的(注入幽默之类的)。
【问题讨论】:
-
从 $text 中删除 /n/r 字符(它们在您的第一个文本中不可见。)
标签: php