Ok, here is the situation. I want to build a dictionary style application (of technical terms), ie you type in a word in a search box or click on a link and you get a definition for that word. Within that definition, if there are words used that also exist within the dictionary, I want them linked to the appropriate definition. I want the linking to happen automatically and dynamically (I don't add links to all the definitions, the code does based on the existance of a definition in the database). I am building this out in PHP 4.04 with a MySQL backend.
I have a good concept of the database model necessary, and actually can think of several ways to do this, but I am wondering if they scale well, should the list of words get rather large, or if there is something that I am missing here.
The only method I have thought of is to build out an array or a long string and do a regular expression replace on it, ie:
$definition = preg_replace('/browse|web/i',"<a href=definitions.php?search=$0>$0</a>",$definition);
except that browse|web would be an incredibly large string of all the definitions in the database, alternately, I could use an array for the first argument. This seems terribly brute force, is there a more elegant way that anybody knows?
Thanks,
David