PHP-求段PHP正则代码求大神帮忙
<div class="ks-waterfall item">
<div class="photo">
<a title="浮云无视" href="链接b" data-pinit="registered" width="210" height="210" />
<span class="alpha-bg"></span>
</a>
<div class="mask">
<span class="like">
<a class="J_Trigger" href="#" data-item="链接A"><em class="J_Counter">0</em></a>
</span>
</div>
</div>
<ul class="details">
<li class="price"><em>¥306</em><span class="sales">
<i class="icon-tamll"></i>
已售出4123件</span>
</li>
<li class="comment-info">
<span class="comment-title">jixianghome99:</span>
<span title="浮云无视">浮云无视</span>
</li>
<li class="more">
<span class="like">
<a href="#" class="hotsale-btn tiny J_Trigger" data-item="13910590073">
<span><i></i> <em class="J_Counter">0</em> </span>
</a>
</span>
<span class="comment">
<a class="hotsale-btn tiny" href="链接b">
<span><i></i> 6721 </span>
</a>
</span>
</li>
</ul>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
<?php
$preg = array('/(?is)href="链接b"/');
$replace = array('href="链接A"');
$str = <<<EOT
<div class="ks-waterfall item">
<div class="photo">
<a title="浮云无视" href="链接b" data-pinit="registered" width="210" height="210" />
<span class="alpha-bg"></span>
</a>
<div class="mask">
<span class="like">
<a class="J_Trigger" href="#" data-item="链接A"><em class="J_Counter">0</em></a>
</span>
</div>
</div>
<ul class="details">
<li class="price"><em>¥306</em><span class="sales">
<i class="icon-tamll"></i>
已售出4123件</span>
</li>
<li class="comment-info">
<span class="comment-title">jixianghome99:</span>
<span title="浮云无视">浮云无视</span>
</li>
<li class="more">
<span class="like">
<a href="#" class="hotsale-btn tiny J_Trigger" data-item="13910590073">
<span><i></i> <em class="J_Counter">0</em> </span>
</a>
</span>
<span class="comment">
<a class="hotsale-btn tiny" href="链接b">
<span><i></i> 6721 </span>
</a>
</span>
</li>
</ul>
</div>
EOT;
echo preg_replace($preg, $replace, $str);
这是个比较简单 具体还得看你的链接
需要正则么 ... 字符串替换 str_replace 就可以了 ..?