lib_filter - An HTML filtering library in PHP

By Cal Henderson

This PHP library allows you to accept HTML input from your users, filter it to make sure it contains only an allowed set of tags, attributes and values and then display it without leaving yourself open to XSS holes.

You can read about the basis of this code in PHP : Processing HTML and again in part 2.