What’s the best method for detecting tags with PHP?

I would like users to be able to insert tags like the following:

Lorem ipsum dolor sit amet, {module_user_name, 123} consectetur adipiscing elit.

As you can see in the example above, the tag has a couple of arguments. The first being the function required, and the arguments will depend on the function requested.

So I would use regex to detect the { and }, feedback? I would then grab the first argument and check to see if it exists.

If it does exist, I would use a good naming convention to avoid having to use a massive IF ELSE or switch script. Like module_user_name would fire the moduleUserName() function, or something like that, feedback?

** This is just my thoughts on how to solve this problem and I’m just wondering if anyone could improve it or point out any issues with speed etc.

Leave a Reply


Hire Me
Follow Me!
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.