How can the highlight_string() function be used as a callback for highlighting PHP code?

The highlight_string() function can be used as a callback for highlighting PHP code by passing it as a parameter to the array_map() function. This allows us to apply the highlight_string() function to each element of an array containing PHP code snippets. By using this approach, we can easily highlight PHP code without the need for manual iteration.

$php_code_snippets = ['<?php echo "Hello, World!"; ?>', '<?php $num = 5; echo $num * 2; ?>'];

$highlighted_code = array_map('highlight_string', $php_code_snippets);

foreach ($highlighted_code as $code) {
    echo $code;
}