Q:

Find and replace problem

My website, has 2 database tables. 1 of them have the posts_table and the other one have the videos.
At the moment i am getting the text images etc , normally from the post_table table.
In my CMS when we add a video there is added a short code 
[media id=487 width=660 height=440]

This shortcode automaticly get the link of a video  from the vid_table where the id is the same as the shortcode.
So what i want is:

I need to do the same thing that the short code do, when a video is added on CMS  the short code is showed in the post, i need to delete the shortcode and instead of it want to be played a video that has the link on the vid_table.

I have some problems with my english , so if you dont understand again please tell me.
Any kind of help will be great.
Thank you.
EDITED: So i  want to replace the whole media tag with a flash player, that plays the url that belongs to the ID in the media tag
BUMP !! CAN HELP PLEASE ?

A:

This is quite a sophisticated problem actually. I was bored and made a basic tag parser. Right now it has some problems: 

HTML rendering should be implemented in a separated class (and a template engine such as Twig should do the rendering);
Tag parsing is way too naive and will probably give you unexpected results if a tag's syntax is incorrect;
[media] tag does not support IE. You would have to change the source itself (method TagParser::renderMedia())

Some features to note:

extra parameters will be rendered as attributes for [link] tag, e.g [link id=25 class=foo] will output <a href="example.com" class="foo">example</a>.
parameters may contain spaces if you quote them: [link id=25 class="foo bar"] will output <a href="example.com" class="foo bar">example</a>
If DataProvider::findById() does not return a 'content' in its array, the parser will output <a href="http://example.com">http://example.com</a>

The code is too long to paste here, you can find it on gist. Just put each file in the directory specified by the first commented line and you should be set. Run example.php to see it in action. You can find out some more details about using this script by looking at the unit test.

