How to remove html tags from string in accessor
Hey Guys, i wanted to change my string to show from Hello to hello in view buy escaping HTML tags by defining an accessor.
public function getDescriptionAttribute()
{
return htmlspecialchars_decode($this->description);
}
Something like this as above code is not working?
strip_tags("Hello
world
")
This might work
This is removing the tags but if i use Hello then hello should appear in bold but it is not happening.
Are you using {!! ... !!} tags in your blade templates as the standard {{ ... }} tags are automatically passed through htmlspecialchars?
it would really help if you did not keep trying to post html in the forum
use backticks around your html
Like @NasirNobin said just use a getter setter or a helper function to strip tags:
public static function fixStr($rvalue)
{
$rvalue = empty($rvalue) && !is_numeric($rvalue) ? NULL : trim(strip_tags($rvalue));
return $rvalue;
}
Note I get the two confused, accessor, mutator. I just use the terms getter and setter.
But in one part you say:
How to remove html tags
Another part:
change my string to show from Hello to hello in view buy escaping HTML tags by defining an accessor.
If all you are doing is making a word lower case you can do that direct:
$whatever = strtolower($whatever);
But yes you can make an accessor if you wish to do that.
Please or to participate in this conversation.