How to apply Zend_Filter_StripTags to an array in zendFramework?

I want to apply Zend_Filter_StripTags to an array of objects

 $my_result = $obj->listdata(calling select query from model) 
Return array

looks like

 $my_result = array 0 => array 'id' => string '1' (length=1) 'value' => string '<script>' (length=10) 1 => array 'id' => string '2' (length=1) 'value' => string '<div>value</div>' (length=15) 

how to apply Zend_Filter_StripTags to $my_result

and I pass this array to smarty

+4
source share
2 answers
 $my_result = $obj->listdata(calling select query from model); $filter = new Zend_Filter_StripTags(); $result = array_map(array($filter, 'filter'), $my_result); 
0
source

Try:

 $allowed_tags = array('img', 'a', 'strong', 'span'); $allowed_attributes = array('alt', 'href', 'width', 'height'); $filter = new Zend_Filter_StripTags($allowed_tags, $allowed_attributes); $output = array_map(array($filter, 'filter'), $my_result); 

Not tested due to lack of env.

Edit:

After you inserted the var dump, try the following:

 $allowed_tags = array('img', 'a', 'strong', 'span'); $allowed_attributes = array('alt', 'href', 'width', 'height'); $filter = new Zend_Filter_StripTags($allowed_tags, $allowed_attributes); $output = array(); foreach ( $my_result as $data ) { $data['value'] = $filter->filter($data['value']); $output[] = $data; } 
0
source

Source: https://habr.com/ru/post/1396802/


All Articles