Description
I want to remove special characters from string on my data-table under "description",
so once i add {!! !!} my table will changed
``` {!! Str::limit($post->description, 15) !! } ```
View Code
<tbody>
@foreach($posts as $post)
<tr>
<td class="py-1">
<img src=" {{ $post->gallery->image }}" style="width: 40px" alt="image" />
</td>
<td> {{ $post->title}} </td>
<td> {!! Str::limit($post->description, 15) !!}</td>
<td> {{ $post->category->name}} </td>
<td> {{ $post->is_publish == 1 ? 'Published' : 'Draft'}} </td>
<td>
<a href=" {{ route('posts.show', $post->id) }} " class="btn btn-sm btn-success"><i class="fas fa-eye"></i></a>
<a href=" " class="btn btn-sm btn-info"><i class="fas fa-edit"></i></a>
<a href=" " class="btn btn-sm btn-danger"><i class="fas fa-trash"></i></a>
</td>
</tr>
@endforeach
</tbody>
You can skip the styling using strip_tags helper and you don't need to escape the html.
Solutions
~~~
{{ strip_tags(Str::limit($post->description, 15)) }}
~~~
Then it will print the description without html.
0 Likes 2 Comments
OG Designs Author
Thank you Admin for your respond. Its works like this: {!! Str::limit(strip_tags($post->description), 15) !!} But in my database (myphpadmin) is still show html tags <span style="font-family: ubuntu-light, sans-serif...
Hadayat Niazi Super Admin
Sonam Ojha
you can use the preg_replace if you want to remove special characters from string example is this {!! Str::limit(preg_replace('/[^A-Za-z0-9\s\-]/', '', $post->description), 15) !!}
yes these styling will help you to display your description in html form, if user created any heading in description so it will display the proper heading, other text will not be readable.