3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function bold($word, $sentence){ $result = preg_replace('~\b(' . preg_quote($word, '~') . ')\b~i', '<span class="found">$1</span>', $sentence); return $result; } $query = 'google'; $description = 'google this and that okay'; $thing = bold($query, $description); echo $thing;
Output for 4.3.0 - 7.2.0
<span class="found">google</span> this and that okay