Hi,

Considering the following script :

====================================================
<?

$dico = array(
     "abaisser"     =>   "def.php?id=9",
     "singer"       =>   "def.php?id=9"
);

$texte = "Abaisser Vous abaisserez la pate, abaisser.Singer";

while(list($mot,$def) = each($dico)) {
$pattern = "(".$mot.")[^[:alpha:]]";
echo "$pattern<BR>";
     $texte = eregi_replace($pattern, "<a href=\"$def\">\\0</a>", $texte);
}

echo $texte;

?>
=========================================================

What I'm trying to do:

I'm trying to have the proper variables for the eregi_replace so that each
word in the $dico array is replaced by a link to its definition respecting
the following rules :
-only exact match makes a link to the definition, for example :
     - "abaisseraient" doesn't make a link
     - "reabaisser" doesn't make a link
     - " abaisser," or "smthg.Abaisser " makes a link on "abaisser" only,
so that the whitespace, comma or dot isn't part of the link
     - "abaisser" a the end of the string make a link

-I don't want to make a link when already in a link :
     - "<a href='some_page.php'>tu peux abaisser le levier</a>" doesn't not
make a link on "abaisser"

I know I'm bad with regex and really need some help on this. This would be
really appreciated.

Regards,

Michael

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to