- str_replace: documentation ( source)
<?php
$word="the";
$replaceWith = "<span class=\"found\">".$word."</span>";
$sentence = "Hello, did you hear the quick brown fox jumped over the lazy dog";
$edited = str_replace($word, $replaceWith, $sentence);
echo $edited;