- Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- <strong>Cat</strong> in the <strong>hat</strong> that had cataract surgery
<?php
$safeWords = array_map('preg_quote', explode(' ', 'hat cat'));
$text = 'Cat in the hat that had cataract surgery';
$regex = '#\b(?:' . implode('|', $safeWords) . ')\b#iu';
echo preg_replace($regex, '<strong>$0</strong>', $text);