Okay, so I have some whole pages that are stored in mysql as longtext. News articles, comments, that sort of thing.

I also have a table with names that I would like to make links whenever they come up in this text.

for discussion sake, lets get some names.
'$newsarticle' is my display text, I want to add the links to this.
'people' is a database with a name field that I want to match up and create links in $newsarticle. It also has an id field that will be needed to link to the data in this 'people' database.

Would this be way too slow? (syntax probably wrong)
$sql="select name, id from people";
    //some magic code to insert anchor tag before and after
    //the $name occurance and then reset the offset to after the first match
I don't know that that magic code would be, I guess a replace.

Which brings me to the point of whether using strreplace would be better.

I notice that you can use an array for the first and second values of the strreplace. If the first array was a list of all the names, and the second was an array with all the html links that would be pretty nice.

How do you go from:
$sql="select name, id from people";

to an array filled with all the returned names, and another array filled with all the returned names but with link data containing that id something like "<a href=/personal-info/id>name</a>" I know I could do it in a loop, but is there some faster with with an explode or implode and some fixed formatting?

My unease here is that I don't really understand what $result is. Is it just simply an array of associative arrays? Or is the fact that it is a resource mean it has to be handled specially. Can I go into $result and just grab the id number from the third returned result (index 2 I assume)?