- Son görülme
- Katılım
- 7 May 2022
- Mesajlar
- 340
- Ödüller
- 8
- Hobi/Meslek
-
İçerikte bulunan tüm linklere nofollow etiketi ekler.
PHP:
<?php
function NoFollow($icerik) {
preg_match_all("/<a.*? href=\"(.*?)\".*?>(.*?)<\/a>/i", $icerik, $matches);
for($i=0;$i<count($matches[0]);$i++){
if(!preg_match("/rel=[\"\']*nofollow[\"\']*/",$matches[0][$i])){
preg_match_all("/<a.*? href=\"(.*?)\"(.*?)>(.*?)<\/a>/i", $matches[0][$i], $matches1);
$icerik = str_replace(">".$matches1[3][0]."</a>"," rel=\"nofollow\">".$matches1[3][0]."</a>",$icerik);
}
}
return $icerik;
}
//Kullanım
$icerik = '<a href="https://siteadı.com">Siteme</a>a git';
echo NoFollow($icerik);
//Çıktı
// <a href="https://siteadı.com" rel="nofollow">Siteme</a>a git
?>