PHP正则提取 DIV CLASS 数据
<divclass="lot-nums"><spanclass="no7"></span><spanclass="no8"></span><spanclass="no5"...
<div class="lot-nums">
<span class="no7"></span>
<span class="no8"></span>
<span class="no5"></span><span class="no9"></span><span class="no2">
</span><span class="no4"></span><span class="no6"></span><span class="no0">
</span><span class="no3"></span> <span class="no1"></span>
</div>
请问如何用PHP提取class里边的 数据 然后 将no前缀去除。
no7 no8 no5 no9 no2 no4 no6 no0 no3 no1
7 8 5 9 2 4 6 0 3 1 展开
<span class="no7"></span>
<span class="no8"></span>
<span class="no5"></span><span class="no9"></span><span class="no2">
</span><span class="no4"></span><span class="no6"></span><span class="no0">
</span><span class="no3"></span> <span class="no1"></span>
</div>
请问如何用PHP提取class里边的 数据 然后 将no前缀去除。
no7 no8 no5 no9 no2 no4 no6 no0 no3 no1
7 8 5 9 2 4 6 0 3 1 展开
1个回答
展开全部
用PHP正则表达式匹配,就可以提取class里面的数据,并将no去除,完整的PHP程序如下
<?php
$str='<div class="lot-nums"><span class="no7"></span><span class="no8"></span><span class="no5"></span><span class="no9"></span><span class="no2"></span><span class="no4"></span><span class="no6"></span><span class="no0"></span><span class="no3"></span> <span class="no1"></span></div>';
$regex='/<span class="no(\d+)"/i';
preg_match_all($regex,$str,$result);
print_r($result[1]);
?>
运行结果
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询