English 中文(简体)
如何按行长度限制 PHP 的文字?
原标题:How Do I Limit Text By Line Length In PHP?

我目前正在开发一个 CMS, 并想添加用行长度限制文本节选的功能。 说我想通过控制显示文本的行数来控制文本的显示,并确保所有区块的高度相同。

有没有人知道任何预写功能 或帮助我开工的文章? 非常感谢。谢谢。谢谢。

最佳回答

您可以使用 http://php.net/ manual/ en/ opident. wordwrap.php" {code> wordlobinf () 函数来控制每行允许的字符数。 此函数还将允许您限制您想要显示的行数, 通过在断开序列上爆炸结果, 并且将生成的数组值组合在一起 。

$s = "This is the long string I wish to wrap to multiple lines.";

list( $one, $two ) = explode( PHP_EOL, wordwrap( $s, 25, PHP_EOL ) );

# This is the long string I wish to wrap to multiple...
echo "$one $two...";

这里我将每一行限制在最多25个字符上。然后,我将前两行打印出来,一个又一个地打印出来。

说明:http://codepad.org/8aCusZGQ>http://codepad.org/8aCusZG/a>

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签