Hi Everyone,

I'm new to PHP, and am learning a lot by reading posts here and two PHP
books.

I'm going to be writing some content management scripts, and one thing I
want to do is allow writers to embed some simple codes in their text such
as:

    [LINK=http://www.mysite.com]Click here for info.[/LINK]

which, when pulled from the database (MySQL) will be parsed into a valid
HTML "a href" command as follows:

    <a href = "http://www.mysite.com";>Click here for info.</a>

First of all, is this a wise thing to do, or will this drastically slow down
the script if it has to parse several pages of text? Second, which of the
various PHP commands would accomplish this the most efficiently? Is
preg_replace() the way to go?

I'm also going to have a database table called IMAGES that stores all image
files (actually, just the URLs to the images on the server), each of which
will be assigned an Article ID number so it can be associated with a
particular article stored in the ARTICLE table. The IMAGE table will also
contain a field called Position where I can indicate the order of the images
for a particular article. I'd like to enter the following in the text of an
article:

    [IMAGE=1]

...and have PHP parse this "code," grab the image URL from the IMAGE table
where the Article ID = the current article being parsed and Position = 1, so
it can replace the above code with an "img src" HTML command as follows:

    <img src=myimage.jpg>

Could this also be accomplished with the preg_replace() command, or is there
a better way to tackle this?

Sorry for the long question. Hope it makes sense.

Thanks!

 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to