Php 有没有办法限制echo$row中的字符->;可变点火器
我目前正在开发一个CMS,并希望添加一个功能,限制其行长度的文本摘录。假设我想控制文本的显示,并通过控制显示的文本行数来确保所有块的高度相同。我使用for each来显示收件箱功能消息数据。在消息部分,它显示了完整的消息,我想将其限制为30Php 有没有办法限制echo$row中的字符->;可变点火器,php,codeigniter,Php,Codeigniter,我目前正在开发一个CMS,并希望添加一个功能,限制其行长度的文本摘录。假设我想控制文本的显示,并通过控制显示的文本行数来确保所有块的高度相同。我使用for each来显示收件箱功能消息数据。在消息部分,它显示了完整的消息,我想将其限制为30 <?php if(isset($records)) : foreach($records as $row) : ?> <tr > <td class="r
<?php
if(isset($records)) :
foreach($records as $row) :
?>
<tr >
<td class="right"><?php echo $row->contactus_name; ?></td>
<td class="right"><?php echo $row->contactus_email; ?></td>
<td class="right"><?php echo $row->contactus_phone; ?></td>
<td class="right tertiary-text-secondary text-justify"><?php echo $row->contactus_comment; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot></tfoot>
</table>
<?php else : ?>
<p>No records</p>
<?php endif; ?>
没有记录
//在控制器中
$this->load->helper('text');
<?php echo word_limiter($row->contactus_comment,30); ?>
$this->load->helper('text');
//在控制器中
$this->load->helper('text');
<?php echo word_limiter($row->contactus_comment,30); ?>
$this->load->helper('text');
如果控制器中包含文本
帮助程序:
$this->load->helper('text');
或者在autoload.php
中:
$autoload['helper'] = array('url', 'form', 'html', 'text');
然后可以使用word\u limitor()
从:
还有字符限制器()。同样,从文档中:
$string = "Here is a nice text string consisting of eleven words.";
$string = character_limiter($string, 20);
// Returns: Here is a nice text string…
如果在控制器中包含文本帮助程序:
$this->load->helper('text');
或者在autoload.php
中:
$autoload['helper'] = array('url', 'form', 'html', 'text');
然后可以使用word\u limitor()
从:
还有字符限制器()。同样,从文档中:
$string = "Here is a nice text string consisting of eleven words.";
$string = character_limiter($string, 20);
// Returns: Here is a nice text string…
谢谢你,非常简单,我之前添加了这个,但它对我不起作用。因为我忘了添加助手。不管怎样,谢谢你。这种情况有时会发生:)谢谢你,非常简单,我之前添加了这个,但它对我不起作用。因为我忘了添加助手。无论如何,谢谢你。这种情况有时会发生:)