比如在一个html模版里,有以下字符串
{/b}
{/b}
{/b}
{/b}
{/b}
我想把每个{/b}替换成不同的字符串,比如:
{/aa_1}
{/aa_2}
{/aa_3}
{/aa_4}
{/aa_5}
...........
请问使用PHP代码如何实现?
通过正则实现了,不过先不结贴看看有没有更好的方法。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
使用 str_replace 或 strtr 就可以实现:
str_replace()
这些就不能看文档么
难道正则不是最好的办法?