PHP removing html tags from string

html, php

Solution

Try to put it like that

$content = strip_tags($text);

Or you can do it with regular expression like that:

$content = preg_replace('/<[^>]*>/', '', $text);

By this `$content = strip_tags($text, '<p>');` you are allowing the `<p>` tag in the string.

For more info see the link http://php.net/manual/en/function.strip-tags.php

Problem

I have string: ``` <p justify;"="">Vers­lo cent­rai Lie­tu­vos ne­kil­no­ja­mo­jo turto plėt­ros aso­cia­ci­jos kon­kur­se ...</p> ``` and want want remove tag ``` <p justify;"=""></p> ``` my code: ``` $content = strip_tags($text, '<p>'); ``` but i get empty string: `string(0) ""` , what I do wrong ?

Original source

Related problems