求正則此文本。。 並且分開輸出

來源:互聯網
上載者:User
本帖最後由 zzqqdwc 於 2013-08-07 11:14:42 編輯

如果。標題 跟 URL分開




jsonCallback({qqmusic:{curtime:1375842150,issmarter:0,systemtime:1375842150,xmusicnum:2,playlist:{song:[{xqusic_id:1384750964,xctype:1,xexpire_time:0,xsong_name:"aa",xsinger_id:0,xsinger_name:"bb",xsong_url:'http://tlly.com/new/eWebEditor/UploadFile/2013870432324.mp3',xsong_dissid:0,xsong_diskname:"",xdesc:"",xquote:0,xkey:"",xclass:0,xsong_playtime:0,xsong_size:0,xis_word:0,xcopy_right:0},{xqusic_id:4886238,xctype:12,xexpire_time:1374058332,xsong_name:"你把我灌醉",xsinger_id:13948,xsinger_name:"鄧紫棋",xsong_url:'http://stream6.qqmusic.qq.com/16886238.wma',xsong_dissid:430766,xsong_diskname:"你把我灌醉",xdesc:"",xquote:0,xkey:"",xclass:0,xsong_playtime:285,xsong_size:2458170,xis_word:0,xcopy_right:0,fbit:1,hd:11410487,ks:4564316,hr:320,soso:0,ape:30765297,flac:31518683,ogg:6363997}]}}})

如echo "標題" .$a. "URL" .$b. "
"


謝謝了 線上等大神 有其它的方法也可以,


回複討論(解決方案)

$s =<<< JSsonCallback({qqmusic:{curtime:1375842150,issmarter:0,systemtime:1375842150,xmusicnum:2,playlist:{song:[{xqusic_id:1384750964,xctype:1,xexpire_time:0,xsong_name:"aa",xsinger_id:0,xsinger_name:"bb",xsong_url:'http://tlly.com/new/eWebEditor/UploadFile/2013870432324.mp3',xsong_dissid:0,xsong_diskname:"",xdesc:"",xquote:0,xkey:"",xclass:0,xsong_playtime:0,xsong_size:0,xis_word:0,xcopy_right:0},{xqusic_id:4886238,xctype:12,xexpire_time:1374058332,xsong_name:"你把我灌醉",xsinger_id:13948,xsinger_name:"鄧紫棋",xsong_url:'http://stream6.qqmusic.qq.com/16886238.wma',xsong_dissid:430766,xsong_diskname:"你把我灌醉",xdesc:"",xquote:0,xkey:"",xclass:0,xsong_playtime:285,xsong_size:2458170,xis_word:0,xcopy_right:0,fbit:1,hd:11410487,ks:4564316,hr:320,soso:0,ape:30765297,flac:31518683,ogg:6363997}]}}})JS;preg_match_all('/xsong_(name|url):([^,]+)/', $s, $r);foreach($r[1] as $i=>$v) {  echo ($v == 'name' ? '標題' : 'URL') . $r[2][$i] . ($v == 'url' ? '
' . PHP_EOL : '');}
標題"aa"URL'http://tlly.com/new/eWebEditor/UploadFile/2013870432324.mp3'

標題"你把我灌醉"URL'http://stream6.qqmusic.qq.com/16886238.wma'

$s=<<  
Array
(
[qqmusic] => Array
(
[curtime] => 1375842150
[issmarter] => 0
[systemtime] => 1375842150
[xmusicnum] => 2
[playlist] => Array
(
[song] => Array
(
[0] => Array
(
[xqusic_id] => 1384750964
[xctype] => 1
[xexpire_time] => 0
[xsong_name] => aa
[xsinger_id] => 0
[xsinger_name] => bb
[xsong_url] => http://tlly.com/new/eWebEditor/UploadFile/2013870432324.mp3
[xsong_dissid] => 0
[xsong_diskname] =>
[xdesc] =>
[xquote] => 0
[xkey] =>
[xclass] => 0
[xsong_playtime] => 0
[xsong_size] => 0
[xis_word] => 0
[xcopy_right] => 0
)

[1] => Array
(
[xqusic_id] => 4886238
[xctype] => 12
[xexpire_time] => 1374058332
[xsong_name] => 你把我灌醉
[xsinger_id] => 13948
[xsinger_name] => 鄧紫棋
[xsong_url] => http://stream6.qqmusic.qq.com/16886238.wma
[xsong_dissid] => 430766
[xsong_diskname] => 你把我灌醉
[xdesc] =>
[xquote] => 0
[xkey] =>
[xclass] => 0
[xsong_playtime] => 285
[xsong_size] => 2458170
[xis_word] => 0
[xcopy_right] => 0
[fbit] => 1
[hd] => 11410487
[ks] => 4564316
[hr] => 320
[soso] => 0
[ape] => 30765297
[flac] => 31518683
[ogg] => 6363997
)

)

)

)

)
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.