如何通过PHP读取特定的json

时间:2018-07-26 06:03:02

标签: php json

我是新来的人,在使用PHP处理json时遇到了一些麻烦。显然,每个json都是不同的,这给我自己造成了一些问题。 json是here。我有一些基本的php启动,这给了我一个数组/对象,但我无法满足需要。

我只需要音乐人和曲目标题

$json_string = 'https://api.acrcloud.com/v1/monitor-streams/s-bVX73QK/results?access_key=4709cb1d4bf05a8e782034797f7a8189';
$jsondata = file_get_contents($json_string);
$obj = json_decode($jsondata,true);
var_dump(json_decode($json_string, true));
print_r($obj);

请给我以下内容

NULL Array ( 
    [0] => Array ( 
        [status] => Array ( 
            [msg] => Success 
            [code] => 0 
            [version] => 1.0 
        ) 
        [result_type] => 0 
        [metadata] => Array ( 
            [type] => real-time 
            [timestamp_utc] => 2018-07-26 03:00:48 
            [music] => Array ( 
                [0] => Array ( 
                    [album] => Array ( 
                        [name] => 17 
                    ) 
                    [play_offset_ms] => 6160 
                    [sample_begin_time_offset_ms] => 3840 
                    [title] => 17 
                    [result_from] => 3 
                    [release_date] => 2017-09-01 
                    [sample_end_time_offset_ms] => 8780 
                    [genres] => Array ( 
                        [0] => Array ( 
                            [name] => Dance 
                        ) 
                    ) 
                    [label] => Columbia 
                    [duration_ms] => 196280 
                    [score] => 100 
                    [db_begin_time_offset_ms] => 0 
                    [artists] => Array ( 
                        [0] => Array ( 
                            [name] => **MK** 
                        ) 
                    ) 
                    [db_end_time_offset_ms] => 5380 
                    [external_ids] => Array ( 
                        [isrc] => GBARL1701492 
                        [upc] => 886446683140 
                    ) 
                    [acrid] => 80538cd22ac21893492c106906c70169 
                    [external_metadata] => Array ( 
                        [spotify] => Array ( 
                            [album] => Array ( 
                                [name] => 17 
                                [id] => 0K1826JxL1dViQBsEKApN5 
                            ) 
                            [track] => Array ( 
                                [name] => 17 
                                [id] => 15DwFznkBJir7AK9PyMyRR 
                            ) 
                            [artists] => Array ( 
                                [0] => Array ( 
                                    [name] => MK 
                                    [id] => 1yqxFtPHKcGcv6SXZNdyT9 
                                ) 
                            ) 
                        ) 
                        [deezer] => Array ( 
                            [album] => Array ( 
                                [name] => 17 
                                [id] => 46039252 
                            ) 
                            [track] => Array ( 
                                [name] => 17 
                                [id] => 393116082 
                            ) 
                            [artists] => Array ( 
                                [0] => Array ( 
                                    [name] => MK 
                                    [id] => 148517 
                                ) 
                            ) 
                        ) 
                    ) 
                ) 
                [1] => Array ( 
                    [album] => Array ( 
                        [name] => All I Need 
                    ) 
                    [play_offset_ms] => 134720 
                    [sample_begin_time_offset_ms] => 0 
                    [title] => All I Need 
                    [result_from] => 3 
                    [release_date] => 2018-05-04 
                    [sample_end_time_offset_ms] => 1940 
                    [label] => Epic Amsterdam 
                    [duration_ms] => 184000 
                    [score] => 91 
                    [db_begin_time_offset_ms] => 125160 
                    [artists] => Array ( 
                        [0] => Array ( 
                            [name] => Dimitri Vegas & Like Mike & Gucci Mane 
                        ) 
                    ) 
                    [db_end_time_offset_ms] => 127100 
                    [external_ids] => Array ( 
                        [isrc] => BEG851800020 
                        [upc] => 886447088173 
                    ) 
                    [acrid] => fc19f90f4d4c6d879288b06e2abec992 
                    [external_metadata] => Array ( 
                        [spotify] => Array ( 
                            [album] => Array ( 
                                [name] => All I Need (with Gucci Mane) 
                                [id] => 7nOmSjsk3WQcuSvkAysvBF 
                            ) 
                            [track] => Array ( 
                                [name] => All I Need (with Gucci Mane) 
                                [id] => 2OSsMwCiZPC44tJ4OPVSZF 
                            ) 
                            [artists] => Array ( 
                                [0] => Array ( 
                                    [name] => Dimitri Vegas & Like Mike 
                                    [id] => 73jBynjsVtofjRpdpRAJGk 
                                ) 
                                [1] => Array ( 
                                    [name] => Gucci Mane 
                                    [id] => 13y7CgLHjMVRMDqxdx0Xdo 
                                ) 
                            ) 
                        ) 
                    ) 
                ) 
            ) 
        ) 
    ) 
) 

究竟如何将Artist(在这种情况下为MK)和音轨名称(在这种情况下为17)打印出来?

0 个答案:

没有答案