如何自动换行回音描述

Am i using wordwrap right? cause its not working. didn't know that simply echo does wrap text..

<p><?php echo wordwrap(ucfirst($row->description), 10);?></p>

By default, wordwrap inserts ASCII linebreaks (). When you want to visually display those linebreaks in HTML use the third parameter of wordwrap and specify <br />.

<p><?php echo wordwrap(ucfirst($row->description), 10, '<br />');?></p>

You can read documentation on all native functions on PHP.net.

In you case, you did not supply a third parameters so it defaults to "" (newline) which you will only see in your source code. You probably want "<br />" as your third parameter.

if you want to truncate the description, you can use mb_substr()

http://php.net/manual/en/function.mb-substr.php