Saibamen
Saibamen

Reputation: 648

How to use strip_tags with second parameter in CodeIgniter?

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

Upvotes: 3

Views: 1898

Answers (2)

Tania Petsouka
Tania Petsouka

Reputation: 1424

Use

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

In second parameter you include all the allowed tags.

Upvotes: 0

alex
alex

Reputation: 490213

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

Upvotes: 3

Related Questions