Extend php support by removing anonymous functions.

Convert anonymous functions used for preg_replace_callback to be methods to extend support for pre 5.3.0 php.