【发布时间】:2021-04-05 16:06:37
【问题描述】:
我正在填充一个 HTML 表格:
<table class="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Event Title</th>
<th>Event snippet</th>
<th>Memory Title</th>
<th>Created at</th>
<th colspan="2">Action</th>
</tr>
</thead>
<tbody>
@foreach($events as $e)
<tr>
<td>{{ $e->id }}</td>
<td>{{ $e->eventname }}</td>
**<td> substr( {{$e->description}}, 0, 24) </td>**
这会产生: 61 事件 40012345 substr(40012345, 0, 24) 60 事件 4001234 substr( 事件有很长的描述。列表应该显示一个 25 字符的子字符串。, 0, 24)
谢谢...Dan'l
【问题讨论】:
-
你可以使用 laravel 的字符串限制辅助方法
{{ Str::limit($e->description, 25) }}