【发布时间】:2013-09-30 00:14:28
【问题描述】:
我对 preg_replace 不是很坚定——换句话说,我不太明白——所以我希望你能帮助我。
我在这样的文本中有一个字符串:[demo category=1] 并想用类别的内容 (id=1) 替换,例如"This is the Content of my first Category"
这是我的起点模式 - 这就是我所拥有的一切:
'/[demo\s*.*?]/i';
希望你能帮忙?
【问题讨论】:
-
您的意思是要将字符串“[demo category=1]”替换为“Content of Category (id=1)”吗?
-
我有例如$content[0]='This is Nr.1' 和 $content[1]='This is Nr. 的数组。 2' - 现在我想用 $content[$categoryid] 替换 [demo category=1]
标签: php regex preg-replace