我试图在以下函数中存储每个竞争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都是整数传递,但我希望它们用逗号分隔。
答案 0 :(得分:0)
这样的东西?
foreach ($getSoccerComp as $key1){
$ids[] = $key1->competition->id;
}
getSoccerByCountry($appKey, $sessionToken, $countrycode, implode(',', $ids));
Sinse你没有对$getSoccerCountry
做任何事情,除了用值null
一遍又一遍地重写变量我删除了obselete代码。