I am populating a HTML table:
JavaScript
x
<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>**
This yields: 61 event 40012345 substr( 40012345, 0, 24) 60 event 4001234 substr( event has a very long description. The list should show a 25 char substring., 0, 24)
Thanks…Dan’l
Advertisement
Answer
Reorganize your html/php:
JavaScript
<td>{{substr($e->description, 0, 24)}}</td>
You can also use Laravel Helpers for string related variables. Read docs here.