1
注意到整数值需要是json
中的整数,但是我正在使用字符串。将数组格式化为JSON以便输入到Google Charts API中?
原始阵列是:
'[{"sctr":"Asset Managers","amount":"1586500"},{"sctr":"Auto
Parts","amount":"1618000"},{"sctr":"Business Support
Services","amount":"1012020"},{"sctr":"Coal","amount":"1043550"},
{"sctr":"Consumer Finance","amount":"2285000"},...
我然后使用下面的代码,以除去键sctr
和amount
:
$sector_final = array();
array_push($sector_final, array("Sector", "Amount"));
foreach($sector_data as $row){
array_push($sector_final, array_values($row));
}
var_dump(json_encode($sector_final));'
给予:
'[["Sector","Amount"],["Asset Managers","1586500"],["Auto
Parts","1618000"],["Business Support Services","1012020"],
["Coal","1043550"],["Consumer Finance","2285000"],
然而的量必须不要在Google Chart Api的引号中起作用。
我该怎么做,还有一种更有效的方法来删除JSON的密钥?