php 使用wordwrap按照用户指定长度进行换行

本范例演示了PHP中wordwrap如何按照用户指定的长度进行换行,感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编来看看吧。
经测试代码如下:

/**
 * wordwrap如何按照用户指定的长度进行换行
 *
 * @param 
 * @arrange (编程之家) jb51.cc
 **/
// create a long text for testing:
$long_text = 'This is a long text to demonstrate the usage of the ';
$long_text .= 'wordwrap function. ';
$long_text .= 'Fooooooooooooooooobar,just fooling around';
 
// Syntax: wordwrap(input string,line max. width,break chars,cut words)
$new_text = wordwrap($long_text,15,<br/>\n,true);
 
print $new_text;
 
/* 
The output will be:
 
This is a long<br/>
text to<br/>
demonstrate the<br/>
usage of the<br/>
wordwrap<br/>
function.<br/>
Foooooooooooooo<br/>
ooobar,just<br/>
fooling around
 
*/


/***   代码来自编程之家 jb51.cc(jb51.cc)   ***/

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...