读书人

请问php处理html源代码方法

发布时间: 2012-08-03 00:12:14 作者: rapoo

请教php处理html源代码方法!在线等
例如:http://www.bengou.com/100408/pm10040810/index.html

其中部分html源代码为:

HTML code
                    <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里的内容,并把所获得的各连接,倒过来排列 ?

请教各位老师,在线等!!

[解决办法]
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);

读书人网 >PHP

热点推荐