How can an anonymous function be used as a wrapper for the callback function in preg_replace_callback?

When using preg_replace_callback, the callback function needs to be a named function. However, if you want to keep the callback function anonymous, you can use an anonymous function as a wrapper for the callback function. This allows you to define the callback logic inline without the need for a separate named function.

// Using an anonymous function as a wrapper for the callback function in preg_replace_callback

$string = "Hello, World!";
$pattern = '/\b\w+\b/';
$replacement = preg_replace_callback($pattern, function($matches) {
    return strtoupper($matches[0]);
}, $string);

echo $replacement;