Remove HTML tags from Strings on laravel blade

后端 未结 4 1127
深忆病人
深忆病人 2021-02-11 16:01

I want remove HTML tags (all) from a string on laravel blade ...

code

{!! \\Illuminate\\Support\\Str::words($subject->body, 5,\'...\')  !!}

相关标签:
4条回答
  • 2021-02-11 16:02

    As for me, I use this construction:

    {!! str_limit(strip_tags($post->text), $limit = 50, $end = '...') !!}
    

    I hope, my code was helpful for somebody)

    0 讨论(0)
  • 2021-02-11 16:19

    You can use strip_tags($yourString); to strip the html tags. In blade you could achieve this by

    {{ strip_tags($yourString) }} 
    //if your string is <h1> my string </h1>
    //output will be my string.
    

    hope that is helpful :)

    0 讨论(0)
  • 2021-02-11 16:21

    You can use

    {{ strip_tags( $value->description ) }}
    
    0 讨论(0)
  • 2021-02-11 16:22

    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:

    $taglessBody = strip_tags($subject->body);
    

    Then pass this variable into a blade template and use it instead of $subject->body.

    0 讨论(0)
提交回复
热议问题