Home >Backend Development >PHP Tutorial >PHP 批量替换内容

PHP 批量替换内容

WBOY
WBOYOriginal
2016-06-23 14:13:451564browse

PHP

需要替换的内容:{1_EXP}{2_EXP}{3_EXP}{4_EXP}{5_EXP}{5_EXP}...

需要替换成:PHP 批量替换内容

例如:
{0_EXP} = PHP 批量替换内容
{1_EXP} = PHP 批量替换内容
{2_EXP} = PHP 批量替换内容
...

PHP:
$row['msg'] = str_replace(表达式, 'PHP 批量替换内容', $mycn['msg']);

什么写?还有其他更好的方法不?



回复讨论(解决方案)

$s='{1_EXP}{2_EXP}{3_EXP}{4_EXP}{5_EXP}{5_EXP}';echo preg_replace('/\{(\d+)_EXP\}/','<img  src="http://localhost/images/$1.gif" / alt="PHP 批量替换内容" >',$s);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php 正则匹配 url imgNext article:PHP环境小问题