hallo,
I want to search a text for words I stored in my mysql-database like this:
id|word|translateword|description
1|wonder|shame|...
2|text|song|...
The text is plain text and all words, and ONLY WHOLE words, in the text should replace by words in the database; i.e.
$oldtext = "This is a wonderfull text, what a wonder!";
after replacement
$newtext = "This is a wonderfull song, what a shame!";
"wonder" but not "wonderfull" is replaced - that is the thing!
Does anybody have an idea?
I found this in the www:
$text_dialekt=array();
$abfrage = "SELECT * from $tab_dialekt";
$result = mysql_query($abfrage,$conn);
while ($row = mysql_fetch_array ($result))
{
$text_dialekt[$row["word"]]=$row["translateword"];
}
$dialekt = strtr($dialekt,$text_dialekt);
But strtr() replaces also "wonderfoll" -> "shamefull"
Is there a possible? What should I use instead of strtr() an how should I use it?
Thank you,
tasten