Automatic Search and link method

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 and one guy gave me the code below. But didn't explain how to use it:

function my_add_links_function( $content ){
$search = array (

$replace = array (

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

Can you help?