0

我正在尝试将每个比赛 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 都作为一个整数传递,但我希望它们以逗号分隔传递。

截屏

4

1 回答 1

0

像这样的东西?

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

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

$getSoccerCountry除了用值一遍又一遍地重写变量之外,你什么也没做,null我删除了过时的代码。

于 2016-03-01T20:51:39.633 回答