Skip to content
Advertisement

How to get plain text from html in laravel model?

I’ve a database column named description in which i’ve saved input from tinymce editor. data is something like this,

JavaScript

I can easily display the data in view with following,

JavaScript

But, I need some processing to get 30 words from text with following code in model,

JavaScript

and I’m currently geting empty when I call shortDescription function.

Is there any way to get plain text from $this->description variable ?

Any suggestion help is appreciated.

Advertisement

Answer

You can use strip_tags() php function for get only text,

JavaScript

output,

“Paragliding Paragliding is the recreational and competitive adventure sport of flying paragliders: lightweight, free-flying, foot-launched glider aircraft with no rigid primary structure. The pilot sits in a harness suspended below a fabric wing. “

further details you can see, http://php.net/manual/en/function.strip-tags.php

JavaScript

Blade File

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement