ok - my problem is that i am working on a website for a big ski company. they have descriptions for their ski models. then there is a database table that includes "technology" terms. if one of these terms is found in a description it should be turned into a link to a description for it.
ok - my problem is now: there is one technolgy calles "as" for example: how do i force the code to only replace full words? (and not the "as" in "mASsses") - also, if i already replaced one string: how do i not re-replace (flag) it (f.ex.: 2 terms: "diagonal" and "diagonal force" - diagonal force is first in the database - so it eventually looks like this:
<a href="link.php?id=diagonalforce"><a href="link.php?id=diagonal">diagonal</a> force</a>
since diagonal gets parsed twice.)
ok - my current code looks like this:
function techReplace($text, $cat = 1)
{
//FILL ARRAY: $techResult[ID] = TITLE;
$sql = "SELECT id, title FROM products_technik WHERE cat = " . $cat;
$techResult = mysql_query($sql);
while ($techRow = mysql_fetch_array($techResult)) {
$techKey = $techRow[title];
$technology[$techKey] = "<a href=\"link.php?id=" . $techRow[id] . "\">" . ucwords(strtolower($techRow[title])) . "</A>";
}
$textReturn = $text;
//PARSE TEXT
if (count($technology)) {
foreach ($technology as $key => $value) {
$textReturn = eregi_replace($key, $value, $textReturn);
}
}
return $textReturn;
}
thanks a lot in advance!!!