Automatic Search and link method

Hello,
I want a method to search-and-link method, so that I can link keywords - which have no link currently - on older posts.

For example, I want to search all words Africa and link them with the category page link.

I asked this question on WordPress.org and one guy gave me the code below. But didn't explain how to use it:

function my_add_links_function( $content ){
$search = array (
'Africa'
);

$replace = array (
'Africa'
);

return str_replace ($search, $replace, $content);
}

Can you help?
Thanks