我正在尝试将数组传递给 GoogleChart API,它将接受如下所示的数组:
$arr=array(['Time' , 'Value'],['08' , 100 ],['10' , 200], ['12' , 300]);
$arr=(json_encode($arr));
echo($arr);
//result
[["Time","Value"],["08",100],["10",200],["12",300]]
但是,当我尝试以下列方式从我的数据库创建数组时,我在推入数组的元素周围加上双引号,API 将不接受该数组:
WHILE($rows=mysqli_fetch_assoc($result)) {
$time[]=$rows['Time'];
$entry[]=$rows['Entry'];
};
$count=count($time);
$newarr=array();
for($i=0; $i<$count; $i++) {
$x="[".$time[$i].",".$entry[$i]."]";
array_push($newarr, $x);
};
array_unshift($newarr, ["Time", "Value"]);
echo(json_encode($newarr));
//result
[["Time", "Value"], "[06:08:00,250]", "[08:08:00,230]"]
是否可以创建不带双引号的数组或删除它们?