例如:http://www.bengou.com/100408/pm10040810/index.html其中部分html源代码为:
<div class="subsrbelist center" id="mhlist">
<ul>

<li>
<a title="第8话" href="1270695200772/1270695200772.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第8话)</span> (11页)</a>


</li>

<li>
<a title="第7话" href="1270695205513/1270695205513.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第7话)</span> (12页)</a>


</li>

<li>
<a title="第6话" href="1270695210191/1270695210191.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第6话)</span> (12页)</a>


</li>

<li>
<a title="第5话" href="1270695217633/1270695217633.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第5话)</span> (12页)</a>


</li>

<li>
<a title="第4话" href="1270695221210/1270695221210.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第4话)</span> (16页)</a>


</li>

<li>
<a title="第3话" href="1270695226220/1270695226220.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第3话)</span> (16页)</a>


</li>

<li>
<a title="第2话" href="1270695230252/1270695230252.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第2话)</span> (18页)</a>


</li>

<li>
<a title="第1话" href="1270695233876/1270695233876.html" target="_blank">泡沫王子Prince Bubble <span class="red">(第1话)</span> (12页)</a>


</li>

</ul>
<br class="clearall" />
</div>如何通过php程序获取上述代码中<a title="第1话" href="连接" ,  的所有href里的内容,并把所获得的各连接,倒过来排列 ?请教各位老师,在线等!!

解决方案 »

  1.   

    preg_match_all('/ href="(.*)"/isU',$s,$m);
    print_r(array_reverse($m[1]));
      

  2.   

    jordan大哥:这个没倒过来排序吧?
      

  3.   

    需要把前面的<li>加上去.否匹配会错误.
      

  4.   

    preg_match_all('/<li>.+href="(.*)"/isU',$s,$m);
    $ar=array_reverse($m[1]);
    echo join(',',$ar);
      

  5.   

    正则不合适,把整个页面的 href值 全匹配到了.能再帮忙看看吗 ?
      

  6.   

    preg_match('/<div class="subsrbelist center" id="mhlist">(.*?)<\/div>/is',$s,$m);
    preg_match_all('/<li>.+href="(.*)"/isU',$m[1],$ar);
    $arr=array_reverse($ar[1]);
    echo join(',',$arr);