Php 如何在字符串中用超链接替换单词
我正在尝试构建一个函数,将一个单词转换为超链接。我使用了这个函数Php 如何在字符串中用超链接替换单词,php,Php,我正在尝试构建一个函数,将一个单词转换为超链接。我使用了这个函数 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=
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;
}
函数myseo($t){
$url='http://'。$\u服务器['SERVER\u NAME']。$\u服务器['REQUEST\u URI'];
$a=数组('kid','childs');
$uu=计数($a);
对于($i=1;$i$theseotext=str\u replace($a[i],“”,$t);
应该是
$theseotext= str_replace($a[$i], '<a href="'.$url.'">'.$a[$i].'</a>', $t);
$theseotext=str_replace($a[$i],“”,$t);
然后再试一次,我想它被吓坏了,因为它现在和我一起工作
函数myseo($t){
$url='http://'。$\u服务器['SERVER\u NAME']。$\u服务器['REQUEST\u URI'];
$a=数组('kid','childs');
$uu=计数($a);
$theseotext=$t;
对于($i=0;$i<$uu;$i++){
$theseotext=str_replace($a[$i],“”,$theseotext);
}
返回$theseotext;
}
@Pin Cody:我不知道它为什么会害怕,但我的理论是它是一个孩子。你看,它正在取代孩子和孩子,它一定是一个孩子。D
$theseotext= str_replace($a[$i], '<a href="'.$url.'">'.$a[$i].'</a>', $t);
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;
}