您好我正在尝试将数据推送到这样的数组:
foreach($totalAnalyticsCountrywise['data']['countries'] as $countries){
array_push($mapData, $countries['country'] => $countries['clicks']);
}
但是这显示了netbeans中的红线错误如何推入?
输出必须是:
$mapData = array('IN' => 12, 'USA' => 31, 'RSA' => 24...);
答案 0 :(得分:2)
你不能用键推送数组元素; Documentation
我想这就是你想要实现的目标。
foreach($totalAnalyticsCountrywise['data']['countries'] as $countryData){
$mapData[$countryData['country']] = $countryData['clicks'];
}