ホームページ >バックエンド開発 >PHPチュートリアル >このテキストの正則化を見つけます。 。 個別に出力します

このテキストの正則化を見つけます。 。 個別に出力します

WBOY
WBOYオリジナル
2016-06-23 14:18:23818ブラウズ

この投稿は 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:"Deng Ziqi",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 ) マスターが他の方法を見つけるのを待ちます。


ディスカッションに返信 (解決策)

$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' ? '<br>' . PHP_EOL : '');}
title "aa"URL'http://tlly.com/new/eWebEditor/UploadFile/2013870432324.mp3'2a87851f231f0546ed00aa1a4409038e タイトル「酔ってしまった」 URL'http://stream6.qqmusic.qq.com/16886238.wma'0c6dc11e160d3b678d68754cc175188a

$s=<<<txtjsonCallback({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}]}}})txt;preg_match('/\{.+\}/s',$s,$m);$s= str_replace("'" , '"' , preg_replace('/(?<=[,{])([^,{:]+)\:/s','"$1":',$m[0]));print_r(json_decode($s,true));

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] =&gt; 4886238
[xctype] =&gt;12
[xexpire_time] =&gt; 1374058332
[xsong_name] =&gt;你你把] => 邓紫棋
[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
[そそ] => 0
[猿] => 30765297
[flac] => 31518683
[ogg] => 6363997
)
)
)
)

)

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。