bgfbgfbgf

\r\n" i want to store my value in database after

tag" /> bgfbgfbgf

\r\n" i want to store my value in database after

tag" /> bgfbgfbgf

\r\n" i want to store my value in database after

tag"/>

remove <p> from $description variable before storing in database(laravel)

2.6k Views Asked by At

i am getting value of input tag i.e an textarea converted into Fckeditor as:

"<p>bgfbgfbgf</p>\r\n"

i want to store my value in database after <p> tags get removed.

how should i remove the <p></p> tags from my value. can anyone help me with this.?

3

There are 3 best solutions below

0
Alexey Mezenin On BEST ANSWER

Use strip_tags to remove tags and str_replace to remove \r\n if needed:

strip_tags(preg_replace('/\s+/', '', $string)))
0
sarath s rajendran On
I think this will solve your problem
$text = "<p>bgfbgfbgf</p>\r\n";
$replace = array('<p>','</p>');
$text =  str_replace($replace,'',$text);

This will only remove p tags.

0
HelloSpeakman On

To remove only the <p> and </p> and nothing else use preg_replace and the following regular expression.

$html = "<p>bgfbgfbgf</p>\r\n";
$string = preg_replace('/<p\b[^>]*>(.*?)<\/p>/is', "", $html);