【发布时间】:2015-05-30 00:27:01
【问题描述】:
如何告诉 php 查看 src 属性是否以 'cid:' 开头,如果是,则将其替换为另一个值?
<img src="cid:xx_xxxxxxxx_xxxxxxxxxxxxxxxxxxx" width="544" height="340">
<?php
$new_link = "http://www.example.com'";
preg_replace("#^cid:#", $new_link);
?>
【问题讨论】:
-
更换的时候,你知道xxxx...是什么吗?如果你知道那个 xxxx.. 是什么,你可以构建那个
cid:xxxxxxx...字符串,然后使用str_replace用链接替换它。正则表达式很乱 -
NO 结果总是不同的。
-
cid 链接是通过 html 生成的,因此脚本需要查看 html,如果找到 src="cid:' 则用新字符串替换它们。codepad.viper-7.com/uNaUvZ
标签: php html preg-replace preg-match-all src