How to use wordwrap to format text paragraphs in php_PHP tutorial

WBOY
Release: 2016-07-13 10:03:04
Original
1054 people have browsed it

How PHP uses wordwrap to format text paragraphs

This article mainly introduces the method of PHP using wordwrap to format text paragraphs, involving the use skills of wordwrap function, which has certain reference For reference value, friends in need can refer to it

The example in this article describes how PHP uses wordwrap to format text paragraphs. Share it with everyone for your reference. The specific analysis is as follows:

The wordwrap() function can format text paragraphs according to the specified fixed line length, making the paragraphs look neater

?

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

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.

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");
<🎜>?>
The above code returns the following results ?
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.
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/969351.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969351.htmlTechArticleHow to use wordwrap to format text paragraphs in php. This article mainly introduces how to format text paragraphs in php using wordwrap. , involving the use skills of wordwrap function, with certain reference...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template