Home  >  Article  >  Backend Development  >  How to use wordwrap to format text paragraphs in php, _PHP tutorial

How to use wordwrap to format text paragraphs in php, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:02:46980browse

How PHP uses wordwrap to format text paragraphs,

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

<&#63;php
$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");
&#63;>

The above code returns the following results

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969504.htmlTechArticleHow PHP uses wordwrap to format text paragraphs. This article illustrates how PHP uses wordwrap to format text paragraphs. Share it with everyone for your reference. The specific analysis is as follows: wor...
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