sois wrote:Is this efficient?
shrug I'm not sure... if you did some caching and outputted the content as a static HTML, I'm sure it'd be fine. Do some benchmarking if you're worried about efficiency.
sois wrote:Also, one other thing i didn't mention. Like most sites that have sports articles, I don't want all instances of the word to have links. Just the first.
Ah, yes, that would change things a bit. Try this:
foreach($keywords as $word => $url)
if(($pos = strpos($data, $word)) !== FALSE)
$data = substr_replace($data, "<a href='$url'>$word</a>", $pos, strlen($word));