Thanks to those of you that replied to my request for help last night. However, it seems as though I didn't explain myself properly, for which I apologise.
The Problem
I am storing text in a MySQL database field, and I want to be able to embed a function within that text.
To achieve: Hi, I'm thelovebug, and I'm posting in php_dev I'm putting: Hi, I'm <?php ljuser("thelovebug"); ?>, and I'm posting in <?php ljcomm("php_dev");?>
ljuser() and ljcomm() are two functions that I created, that output HTML similar to that of <ljuser=x> and <lj comm=x>
The Spanner The big spanner in the works, is that PHP does not re-evaluate functions within an echo() construct.
The Solution The solution I'm trying to implement is to create a custom HTML (or something) tag. They way I thought of doing it was to use square brackets to surround the custom "tag". i.e. [lj user=thelovebug] and [lj comm=php_dev]. Then a function (I thought it was preg_replace();) to find all instances of [lj user=*] and fill out the HTML around it. Then I realised that it wouldn't matter whether they were square [] brackets, or angle <> brackets.
What I asked for yesterday went a good way towards this solution, because I could feed the result of the pref_match(); function into my ljuser(); function. However, this doesn't make any allowances for any other text either before or after it.
The Request What I would like is something that will take:
Hi, I'm <lj user=thelovebug>, and I'm posting in <lj comm=php_dev>
(angle or square brackets, I don't mind) ... and convert it into full HTML, making use of the ljuser(); and ljcomm(); functions that I've already written.
A bag of Cheesy Poofs for the first person to give me a workable solution :-)