user347729
user347729

Reputation:

Strip HTML Tags in Zend Framework

I am trying to strip all html tags except <p>,<br>,<strong>,<b> from input data from the following:

    public function init()
{
    parent::init();
    $this->fields = array(
        'name' => 'Name',
        'age' => 'Age',
        'profile' => 'Profile',
    );

    $this->mdata = array();
    $this->verify = true;
}

Anyone knows how to apply Zend_Filter_StripTags in it?

Upvotes: 4

Views: 4477

Answers (1)

Naveed
Naveed

Reputation: 42093

If I understand your problem:

$allowedTags = array('p','b','br','strong'); // Allowed tags
$allowedAttributes = array('href'); // Allowed attributes
$stripTags = new Zend_Filter_StripTags($allowedTags,$allowedAttributes); // instance of zend filter
$sanitizedInput = $stripTags->filter($input); //$input is input html

See this SO answer

Upvotes: 8

Related Questions