douwen3500 2017-07-25 11:24 采纳率: 0%
浏览 16
已采纳

表单字段和标签PHP

I don't what the thing is actually called but I try to descripe.

So I have form with couple fields and textarea. Now what I want is that user could add "tags" to textarea and those tags would then be replaced with variables from db/array in code. So for example if the user writes to textarea "Hello how are you {name} today?" then when the form is saved, the {name} would then be replaced with some string from array. How to do it or what is this method called so I could google and learn more about it?

  • 写回答

1条回答 默认 最新

  • dongxieyi9115 2017-07-25 11:34
    关注

    You're looking for a parser. You can use regular expressions and/or string replacements for that. Typically there would be parsing methods for both encoding and decoding. You could implement a class for that. Those functionalities are often used in forums or cms. The simplest example would be smiley codes. Once you understand the workflow of that, you could even use tag-functions. Such as {ListGroup|25} which could produce a list of 25 users of a group.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?