<p class="sougouContent"> </p> <p class="tag"> PHP </p> 需要替换的内容:{1_EXP}{2_EXP}{3_EXP}{4_EXP}{5_EXP}{5_EXP}... <br> <br> 需要替换成:<img src="http://localhost/images/*.gif" /> <br> <br> 例如: <br> {0_EXP} = <img src="http://localhost/images/0.gif" /> <br> {1_EXP} = <img src="http://localhost/images/1.gif" /> <br> {2_EXP} = <img src="http://localhost/images/2.gif" /> <br> ... <br> <br> PHP: <br> $row['msg'] = str_replace(表达式, '<img src="http://localhost/images/当前名称.gif" />', $mycn['msg']); <br> <br> 什么写?还有其他更好的方法不? <br> <br> <br> <br> <h2>回复讨论(解决方案)</h2> <p class="sougouAnswer"> <div class="code" style="position:relative; padding:0px; margin:0px;"><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" />',$s);</pre><div class="contentsignin">ログイン後にコピー</div></div> </p>