在PHP数组

时间:2016-03-01 20:48:10

标签: php betfair

我试图在以下函数中存储每个竞争ID:

function getSoccerByCountry($appKey, $sessionToken, $country, $competitionid)
{
    $jsonResponse = sportsApingRequest($appKey, $sessionToken, 'listMarketCatalogue', '{"filter":{
                "eventTypeIds": [
                    "1"
                ],"competitionIds":["' . $competitionid . '"],"marketTypeCodes":["MATCH_ODDS"],"marketCountries":["' . $country . '"],"inPlayOnly": true
            },
            "maxResults": "200",
            "marketProjection": [
                "COMPETITION",
                "EVENT",
                "EVENT_TYPE",
                "RUNNER_DESCRIPTION",
                "RUNNER_METADATA",
                "MARKET_START_TIME"
            ]
        },
        "id": 1}
]');

我为每个循环创建了这个循环,它循环数组的每个键值,只获得传递给getSoccerByCountry函数的竞争ID。

foreach ($getSoccerComp as $key1)
{           
    $getSoccerCountry = getSoccerByCountry($appKey, $sessionToken, $countrycode, $key1->competition->id);
}

尽管所有竞争ID都是整数传递,但我希望它们用逗号分隔。

Screenshot

1 个答案:

答案 0 :(得分:0)

这样的东西?

foreach ($getSoccerComp as $key1){           
    $ids[] = $key1->competition->id;
}

getSoccerByCountry($appKey, $sessionToken, $countrycode, implode(',', $ids));

Sinse你没有对$getSoccerCountry做任何事情,除了用值null一遍又一遍地重写变量我删除了obselete代码。