当前位置: 移动技术网 > IT编程>开发语言>PHP > php使用wordwrap格式化文本段落的方法

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

2018年06月28日  | 移动技术网IT编程  | 我要评论

李心洁个人资料,国债etf,郴州在线

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

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

<?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");
?>

上面的代码返回如下结果

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程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网