So something like this
$myvar['tree'] = 'this great tree';
$myvar['apple'] = 'something which grows on a tree';
$keys = array_keys($myvar);
//
// some search things getting me $totalfound and arrays $foundinkey, $wordfound
//
while ($count < $totalfound) {
$myvar['$foundinkey'] = str_replace(' $wordfound', '<a href="url"> $wordfound</a>', $myvar['$foundinkey']);
$count++;
}
Any tips on the commented part?