下面是编程之家 jb51.cc 通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。
str_replace() 函数:使用一个字符串替换字符串中的另一些字符。
举个例子:
[field:sitepath function='str_replace("{cmspath}","http://localhost/",@me) /]
实际上是查找内容中指定的部分然后进行替换,上面是 DEDE 中的应用方法,第 2 个双引号实际是替换的内容,这里是 http://localhost/,上面标签的作用就是查找内容中的{cmspath}并替换为 http://localhost/,实际上也就是去掉。str_replace()还有一个参数 count ,是替换的次数,语法为:
str_replace(find,replace,string,count)
[field:info/]
[field:arcurl/]
[field:typedir/]
举个例子:
[field:title function='str_replace("aaa","bbb",@me)/]
[field:title function='str_replace("测试","test",@me)/]
查找标题中的 aaa 替换成 bbb,但下面这个比较常用,主要应用于二三级栏目嵌套调用中
[field:typedir function='str_replace("{cmspath}","",@me)'/]
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。