How to use strip_tags with second parameter in CodeIgniter?

∥☆過路亽.° 提交于 2019-12-10 19:50:38

问题


How to strip HTML tags, but not all tags? For example i want to have <br>, <b> etc in textareas.

I have this form validation rule:

$this->form_validation->set_rules('user_desc', 'Opis', 'min_length[3]|max_length[200]|xss_clean|strip_tags');

回答1:


Use strip_tags() with the second argument.

$stripped = strip_tags($str, '<b><br>');

You could build an array of allowable elements and then join them for the second argument with...

$allowedElementsJoined = '<' . implode('><', $allowedElements) . '>';



回答2:


Use

strip_tags($string, '<b><br>');

In second parameter you include all the allowed tags.



来源:https://stackoverflow.com/questions/7298944/how-to-use-strip-tags-with-second-parameter-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!