<?php

$text = "<B>FOO</B>";
$text = preg_replace_callback("~(</?)(\w+)([^>]*>)~", function($subs) {
	return $subs[1] . strtolower($subs[2]) . $subs[3]; 
 }, $text);
 echo $text;