Home  >  Article  >  Backend Development  >  php使用wordwrap格式化文本段落的方法_PHP教程

php使用wordwrap格式化文本段落的方法_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:03:041016browse

php使用wordwrap格式化文本段落的方法

 这篇文章主要介绍了php使用wordwrap格式化文本段落的方法,涉及wordwrap函数的使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下

 

 

本文实例讲述了php使用wordwrap格式化文本段落的方法。分享给大家供大家参考。具体分析如下:

wordwrap()函数可以按照指定的固定行长度格式化文本段落,让段落看起来更加整齐

?

1

2

3

4

5

6

7

8

9

10

$string = "TRADING ON MARGIN POSES ADDITIONAL

RISKS AND IS NOT SUITABLE FOR ALL

INVESTORS.

A COMPLETE LIST OF THE RISKS ASSOCIATED WITH MARGIN TRADING IS

AVAILABLE IN THE MARGIN RISK DISCLOSURE DOCUMENT.";

$string = str_replace("\n", " ", $string);

$string = str_replace("\r", " ", $string);

print(wordwrap($string, 40)."\n");

?>

上面的代码返回如下结果

?

1

2

3

4

5

6

TRADING ON MARGIN POSES ADDITIONAL

RISKS AND IS NOT SUITABLE FOR ALL

INVESTORS. A COMPLETE LIST OF THE

RISKS ASSOCIATED WITH MARGIN TRADING IS

AVAILABLE IN THE MARGIN RISK DISCLOSURE

DOCUMENT.

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/969351.htmlTechArticlephp使用wordwrap格式化文本段落的方法 这篇文章主要介绍了php使用wordwrap格式化文本段落的方法,涉及wordwrap函数的使用技巧,具有一定参考借鉴...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn