preg_match_all
正则有点麻烦..

解决方案 »

  1.   

    这个用正则好像有点不现实,既然是HTML的操作试试用DOMDocument操作吧。
      

  2.   

    jakey9826你真是一语惊醒梦中人啊
    太感谢你了
      

  3.   


    $pat = '/<td class=tdn>([0-9]+)<\/td>(.*?)<td>([0-9\.]+) M<\/td>/is';
    preg_match_all($pat,$str,$match);
    print_r($match);Array
    (
        [0] => Array
            (
                [0] => <td class=tdn>1</td><td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳  &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=1" title="请点击左键!来源网址:  http://video2.idaocao.com   请参照百度权利声明使用" onclick="return ow(event,this)"  target="_blank"><font color="#c60a00">心跳</font>  </a></td>
    <td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;</td>
    <td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a>&nbsp;</td>
    <td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳  &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=1&d=9" onclick="return ot(event,this,'624751')">试听</a>&nbsp;</td>
    <td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a>&nbsp;</td>
    <td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=1" onclick="return or(event,this);">铃声</a>&nbsp;</td><td>5.2 M</td>
                [1] => <td class=tdn>2</td>
    <td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳  &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=2" title="请点击左键!来源网址:  http://www.sonymusic.cn   请参照百度权利声明使用" onclick="return ow(event,this)"  target="_blank"><font color="#c60a00">心跳</font>  </a></td>
    <td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;</td>
    <td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a>&nbsp;</td>
    <td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳  &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=2&d=9" onclick="return ot(event,this,'624751')">试听</a>&nbsp;</td>
    <td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a>&nbsp;</td><td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=2" onclick="return or(event,this);">铃声</a>&nbsp;</td><td>6.0 M</td>
            )    [1] => Array
            (
                [0] => 1
                [1] => 2
            )    [2] => Array
            (
                [0] => <td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳  &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=1" title="请点击左键!来源网址:  http://video2.idaocao.com   请参照百度权利声明使用" onclick="return ow(event,this)"  target="_blank"><font color="#c60a00">心跳</font>  </a></td>
    <td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;</td>
    <td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a>&nbsp;</td>
    <td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳  &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=1&d=9" onclick="return ot(event,this,'624751')">试听</a>&nbsp;</td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a>&nbsp;</td>
    <td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=1" onclick="return or(event,this);">铃声</a>&nbsp;</td>            [1] => 
    <td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳  &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=2" title="请点击左键!来源网址:  http://www.sonymusic.cn   请参照百度权利声明使用" onclick="return ow(event,this)"  target="_blank"><font color="#c60a00">心跳</font>  </a></td>
    <td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;<a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a>&nbsp;</td>
    <td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a>&nbsp;</td>
    <td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳  &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=2&d=9" onclick="return ot(event,this,'624751')">试听</a>&nbsp;</td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a>&nbsp;</td>
    <td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=2" onclick="return or(event,this);">铃声</a>&nbsp;</td>
            )    [3] => Array
            (
                [0] => 5.2
                [1] => 6.0
            ))
      

  4.   

    问题就是这样解决的。
    5楼 jakey9826 的无意之言点开了LZ的疑惑。