如何将内容限制为只有一定数量的字符。我想将行数限制为 3 行,每行 6 个单词,并在下一行中显示接下来的 6 个单词。 $row->openletter 给我超过 1000 个单词的完整结果。我已经在 Controller 中加载了文本助手。请找到我想要实现的附加图像。我如何限制 $row->openletter 每行只显示 6 个单词并将行数限制为 3?
<?php
echo "</li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "<div class='news-v2-desc'>";
echo "<h3>";
<a href="<?php $this->load->helper('url'); echo base_url();?>index.php/Welcome/indexes?id=<?php $data=$row->open_id; echo $data; ?>">
<?php $ima=$row->title; echo $ima; ?>
</a>
<?php echo "</h3>";
echo "<small>By Admin | California, US | In <a href='#'>Art</a></small>";
echo "<p>";
$string = word_limiter($row->openletter, 4);
echo $string;
echo "</p>";
echo "</div>";
echo "</div>";
}
?>
最佳答案
试试这个
$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 )
关于javascript - 在 Codeigniter 中将输出限制为仅 3 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34102239/