Fixed preg_replace_callback to not use anonymous function to cater for PHP version < 5.3