wordwrap()函数可以按照指定的固定行长度格式化文本段落,让段落看起来更加整齐
/**
* PHP使用wordwrap重新格式化文本段落
*
* @param
* @arrange 512-笔记网: jb51.cc
**/
$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");
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
上面的代码返回如下结果
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.
原文链接:https://www.f2er.com/php/528370.htmlRISKS 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.