Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将Codeigniter中的输出限制为仅3行_Javascript_Php_Css_Codeigniter - Fatal编程技术网

Javascript 将Codeigniter中的输出限制为仅3行

Javascript 将Codeigniter中的输出限制为仅3行,javascript,php,css,codeigniter,Javascript,Php,Css,Codeigniter,如何将内容限制为仅特定数量的字符。我想将行数限制为3行,每行6个单词,并在下一行中显示接下来的6个单词$row->openletter为我提供了超过1000字的完整结果。我已将文本助手加载到控制器中。请找到我想要实现的附加图像。如何限制$row->openletter每行仅显示6个单词,并将行数限制为3个 试试这个 $para = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem

如何将内容限制为仅特定数量的字符。我想将行数限制为3行,每行6个单词,并在下一行中显示接下来的6个单词$row->openletter为我提供了超过1000字的完整结果。我已将文本助手加载到控制器中。请找到我想要实现的附加图像。如何限制$row->openletter每行仅显示6个单词,并将行数限制为3个

试试这个

$para = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.';

$pos = strpos($para, ' ', 200);
echo substr($para,0,$pos )

根据您的问题,$string=$row->openletter;应分为3行,每行6个字。我想这个代码会满足你的问题。让我知道结果

<?php
$string = "Here is a nice text string consisting of eleven words.Here is a nice text string consisting of eleven words";
$str=explode(' ',$string );//stores each word as a array 
$a=0;
for($i=0;$i<3;$i++){
$a=$a+$i;
$b=$a+1;
$c=$b+1;
$d=$c+1;
$e=$d+1;
$f=$e+1;
$a=$f;
echo $str[$a]." ".$str[$b]." ".$str[$c]." ".$str[$d]." ".$str[$e]." ".$str[$f];
echo"<br>";
}
?>  


您需要如图所示的输出。我说得对吗?你需要6个字三行right@how你接受了阿卜杜拉的回答。他做了替补功能。这不能满足你的问题。你要求每行写6个字,那两行写3个字。它将如何工作?@shank但您已经接受了另一个答案问题解决了吗?@shank请尝试更新的答案。让我知道输出是什么