views:

90

answers:

1

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?

+4  A: 

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

NAVEED
And how do I implement that on my source code above?
webdev28
In your above code, there are just initialization of some variables and calling init() of parent. How do you want to use these with **Zend_Filter_StripTags**
NAVEED
I see, so I suppose I should have the StripTags in other place, thanks for that
webdev28