<?php
$keywords = array('dog', 'cat', 'cow');
$text = 'I own two dogs, four cats, and twenty cows.';
$regexp = '/\b(' . implode('|', $keywords) . ').*?\b/';
echo preg_replace($regexp, '<b>$0</b>', $text);
