If you declare your arrays, and set k to 0 first, put quotes around array
values and use the correct limit (you can default to -1), you will get
results, here is code and example (hopefully this helps you)

       function internal_links($str, $links, $limit=-1) {
               foreach($links AS $link){
                       $pattern[$k] = "~\b({$link['phrase']})\b~i";
                       $replace[$k] = '<a href="'.$link['link'].'">\\1</a>';
               return preg_replace($pattern,$replace,$str, $limit);

echo internal_links("süße knuffige Beagle Welpen ab sofort",
'link'=>"http://wolframalpha.com";)), -1);

süße knuffige <a href="http://google.com";>Beagle</a> <a href="
http://wolframalpha.com";>Welpen</a> ab


Reply via email to