如何在CodeIgniter中使用带有第二个参数的strip_tags? [英] How to use strip_tags with second parameter in CodeIgniter?

查看:192
本文介绍了如何在CodeIgniter中使用带有第二个参数的strip_tags?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何标记HTML标记,但不是所有标记?例如我想在textareas中有< br> < b> 等。

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');


推荐答案

使用 strip_tags()

Use strip_tags() with the second argument.

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

您可以构建一个允许的元素数组,然后连接它们的第二个参数with ...

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

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

这篇关于如何在CodeIgniter中使用带有第二个参数的strip_tags?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆