I've had some success with this, though I'm still a bit gun shy on it.

Code php:
namespace PNL;
 * Extend the root namespace function htmlentities to allow the first
 * argument to be an array or object.  If it is, recurse over it and apply
 * htmlentities to all members. KEYS WILL NOT CHANGE, so if they have html 
 * entities in them you still need to call htmlentities on the element.
 * @param mixed $mixed
 * @param unknown_type $flags
 * @param unknown_type $charset
 * @param unknown_type $double_encode
function htmlentities($mixed, $flags=null, $charset=null, $double_encode=null) {
	if (is_array($mixed) || is_object($mixed)) {
		foreach ($mixed as &$var) {
			$var = htmlentities($var, $flags, $charset, $double_encode);
		return $mixed;
	} else {
		return \htmlentities($mixed, $flags, $charset, $double_encode);

Thoughts (either on the overriding in general or the function itself)?