I want remove HTML tags (all) from a string on laravel blade ...
code
{!! \Illuminate\Support\Str::words($subject->body, 5,'...') !!}
output (example)
<p>hassen zouari</p>
I want that it be like this
hassen zouari
I want remove HTML tags (all) from a string on laravel blade ...
code
{!! \Illuminate\Support\Str::words($subject->body, 5,'...') !!}
output (example)
<p>hassen zouari</p>
I want that it be like this
hassen zouari
use this in your code
$allcms = json_decode(strip_tags(Cms::where('status','active')->get()),true);
Add the below code into your helpers
& use this in your blade
As for me, I use this construction:
I hope, my code was helpful for somebody)
you must know about the diffrence between
{{ }}
and{!! !!}
1.1) laravel have predefined you can load variable exact value by using
{{$a }}
or
1.2)laravel loading with strip remove
{!! $a !!}
please take it seriously this qustion answer its protect your website from cross site scripting excecution.for example if user save his name but he puted script alert.then if you using core php and not handling the strip tags then this script excution when page laod
so i give you some more harmful example 1)like i puted my name as script or in a about section and in script i write some code who get the browser cookies of open website and curl request for saving on my server.
so you understand this whats happen if i got the each user cookies by curl and i just puted a cross script in about filed and its saved in database.
Try to use
strip_tags()
function:http://php.net/manual/en/function.strip-tags.php
Update: Try to do something like this in a controller:
Then pass this variable into a blade template and use it instead of
$subject->body
.You can use strip_tags($yourString); to strip the html tags. In blade you could achieve this by
hope that is helpful :)