Web Analytics Made Easy -
StatCounter Parsing 'dynamic' template tags - CodingForum


No announcement yet.

Parsing 'dynamic' template tags

  • Filter
  • Time
  • Show
Clear All
new posts

  • Parsing 'dynamic' template tags

    hey guys,

    I have a small template system for my website, and I would like to find certain tags in my articles and parse them. This is not a problem, but I ran into a small problem with my image tags. In order to display an image in my articles, I can use something like [img:0] anywhere in my article to display the first image, and [img:1] to display the second image. For each article, I have an array which contains the actual file names, example:


    so I need to look for these [img] tags, and read what 'parameter' has been specified. I was trying to avoid loops, so I tried using preg_replace with the /e modifier, but it looks like you can't pass an array when calling a function in that preg_replace statement. Replacement example:

    "\\1 . my_function($array,'\\2') . '\\3'"

    I receive a parsing error pointing to the my_function parameters (but the actual function is never executed, so it's something with the syntax). The error disappears when I remove $array from the parameters.

    So I gave up on that, and decided some other functions such as preg_match_all etc, but I am running into other issues, plus I have to use a loop, so I am hoping someone can figure out the preg_replace issue. Any suggestions would be appreciated. Thanks!