<p class="sougouContent"> </p> <p class="tag"> PHP </p> 需要替换的内容:{1_EXP}{2_EXP}{3_EXP}{4_EXP}{5_EXP}{5_EXP}... <br> <br> 需要替换成:<img alt="PHP 批量替换内容" > <br> <br> 例如: <br> {0_EXP} = <img alt="PHP 批量替换内容" > <br> {1_EXP} = <img alt="PHP 批量替换内容" > <br> {2_EXP} = <img alt="PHP 批量替换内容" > <br> ... <br> <br> PHP: <br> $row['msg'] = str_replace(表达式, '<img alt="PHP 批量替换内容" >', $mycn['msg']); <br> <br> 什么写?还有其他更好的方法不? <br> <br> <br> <br> <h2>回复讨论(解决方案)</h2> <p class="sougouAnswer"> <pre class="sycode" name="code">$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);</pre> </p>