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