i found this script to unlink links. What happens here is that all links dissapear and become $word:
[code=php]reg_replace(“/<a href=.*>(.*)</a>/”, $word, $string);
But i don’t want every link to change into $word I want only links that have $word in them get unlinked. So i thought of something like this:
[code=php]reg_replace(“/<a href=$word>($word)</a>/”, $word, $string);
this doesn’t work how can I fix this??
This is the full script maybe it helps a external text file is imported and the scripts makes links out of all words in de the text automatically.
[code=php]
<?php
//start sessie
session_start();
header(“Cache-control: private”); // IE6 Fix
//Twee sessie arrays aanmaken
session_register(‘text’);
session_register(‘number’);
//Aantal bezoeken tellen
$_SESSION[‘number’] = $_SESSION[‘number’]+1;
//Alleen in het begin text oproepen
if($_SESSION[‘number’] == 1){
//Zeggen welke text je wilt doen
$text = file(“text.txt”);
//Text op splitsen in apparte woorden om er links van te maken
$split = explode (” “, $text[0]);
//Aantal woorden tellen
$count = count($split);
//For loop om de hele text weer in elkaar te zetten met alle links
for($i = 0; $i <= $count; $i++){
$_SESSION[‘text’] .= “<a href=”.$PHP_SELF.”?word=”.$split[$i].”>”.$split[$i].”</a> “;
//Text weergeven als text helemaal gemaakt is
if ($i == $count){
echo $_SESSION[‘text’];
}
}
}
/*Wanneer we de begin text hebben kunnen we hem de tweede keer
dat we de pagina bezoeken gaan vergaten*/
else {
$_SESSION[‘text’] = preg_replace( “/<a href=.*>(.*)</a>/”, ‘<span style=”color:#000000;font-weight:normal;”>’. $word.'</span>’, $_SESSION[‘text’] );
echo $_SESSION[‘text’];
}
?>