i am trying to build a function to change a word into a hyper link. i used this function
function myseo($t){
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER[开发者_如何学JAVA'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;
}
but it doesnt work with me.
regards Piny
I think it got scared, because it works with me now. ;)
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;
}
Demo
$theseotext= str_replace($a[i], '<a href="'.$url[i].'">'.$a[i].'</a>', $t);
should be
$theseotext= str_replace($a[$i], '<a href="'.$url.'">'.$a[$i].'</a>', $t);
and try again
精彩评论