当前位置:Gxlcms > PHP教程 > preg_replace的使用问题?

preg_replace的使用问题?

时间:2021-07-01 10:21:17 帮助过:19人阅读

本帖最后由 u013747505 于 2014-02-23 16:36:03 编辑

preg_replace


如图所示。在原来的基础上增加一个img标签 地址参数调用前面超文本的参数。
另外一段代码有很多个这样的结构标签 我都要替换。 不能用array了吧?


回复讨论(解决方案)

  1. $html = <<<htmlca<font>sdcasdhtml;preg_match_all('/\s*(?:.*?)<\/a>/i', $html, $match);foreach ($match[0] as $key => $value) {
  2. $newValue = $value."\n<img src="https://www.gxlcms.com/tr.php?hash=".$match[1][$key]."" width="155" heigth="120">";
  3. $html = str_replace($value, $newValue, $html);}var_dump($html);</htmlca<font>

人气教程排行