$1', $string); } } // Hardcoded words and paragraph, normally this would come from a database I would expect $words_to_highlight = array('code','php'); $paragraph = 'This is a very simple php script which highlights words in a string when called. You could use this code to highlight words in search results.'; // Output the string with the specified words highlighted. echo StringHighlighter::HighlightWords($paragraph, $words_to_highlight); ?>