htmllaravellaravel-views

Removing HTML Tags from meta property in Laravel directly in views


I am a loading a variable in Laravel which has some paragraph tags for the meta property"og:description". Is there a way I can remove the paragraph tag directly from the views>x.blade.php

Example:

<p> Hello Work </p>

should appear as:

Hello World

Any helps is always appreciated.


Solution

  • You should be able to achieve that using strip_tags function. You can read about it here.

    You can prepare your variable in the controller and then pass it into blade, or just use it directly in blade like this:

    {{ strip_tags($yourString) }}
    

    Hope this helps!