如何使用PHP从嵌套JSON中提取数据

时间:2017-07-18 20:55:18

标签: php arrays json

我试图搜索JSON以提取一些信息,但我无法完成它。 JSON看起来像这样(它有点混乱):

"d": [{
 "__type": "BetFire.Abstractions.Data.SportItem",
 "Id": 1,
 "Name": "Soccer",
 "ExtUrl": "https://s5.sir.sportradar.com/betinaction/en/match/{0}",
 "Items": [{
     "Id": 384,
     "CountryIso": "AUS",
     "Name": "AUS Victoria Premier League, Australia",
     "MarketsId": -1,
     "ParentId": 1,
     "MarketNames": null,
     "MarketTypeIds": [1,...],
 "Items": [{
        "Id": 636362298000000000,
        "CountryIso": null,
        "Name": "2017/07/21",
        "MarketsId": 0,
        "ParentId": 0,
        "MarketNames": null,
        "MarketTypeIds": null,
        "MarketTabs": null,
        "Items": null,
        "Events": [{
            "EventId": 8937395,
            "EventCodeId": 2210,
            "ExtraPriceCount": 181,
            "EventName": "Oakleigh Cannons vs. Melbourne Knights",
            "EventDate": "\/Date(1500633000000)\/",
            "Prices": [],
            "PrintPrices": null,
            "RacingSelections": null,
            "RacingDetails": null,
                                 etc..

我尝试过这样的事情(在jsondecode之后):

$text = $result['d']['0']['ExtUrl'];
$EventName = $result['d']['Items']['Items']['Events']['EventName'];
echo $EventName;
echo $text;

但我得到" {"结果。

0 个答案:

没有答案