- array_map: documentation ( source)
- print_r: documentation ( source)
- str_replace: documentation ( source)
<?php
$keywords = ['test', 'value'];
$replace = array_map(function($key) {
return '<span>' . $key . '</span>';
}, $keywords);
print_r($replace);
$string = 'Hello world. This is a test.';
$render = str_replace($keywords, $replace, $string);
echo $render;