如何用字符串中的超链接替换单词


how to resplace a word with hyperlink in a string

我正试图建立一个函数来改变一个词变成一个超链接。我使用了这个函数

function myseo($t){
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$a=array('kid','children');
$uu=count($a);
for ($i = 1; $i <= $uu; $i++) {    
$theseotext= str_replace($a[$i], '<a href="'.$url[$i].'">'.$a[$i].'</a>', $t);  
}
return $theseotext;
}

但这对我不起作用。

的问候松树的

我想它被吓到了,因为它现在对我很管用。;)

function myseo($t){
    $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    $a = array('kid', 'children');
    $uu = count($a);
    $theseotext = $t;
    for ($i = 0; $i < $uu; $i++) {
        $theseotext = str_replace($a[$i], '<a href="'.$url.'">'.$a[$i].'</a>', $theseotext);
    }
    return $theseotext;
}

$theseotext= str_replace($a[i], '<a href="'.$url[i].'">'.$a[i].'</a>', $t);  
应该

$theseotext= str_replace($a[$i], '<a href="'.$url.'">'.$a[$i].'</a>', $t);  

,再试一次