我正在尝试解析数组并删除双引号
<?php
include('../db_connect/sql.php');
$tmps = array();
$query = $db->prepare("SELECT temp FROM temperatures WHERE sensor_id='28-000005fd5279' ORDER BY id DESC LIMIT 3");
$query->execute();
$result = $query -> fetchAll();
foreach( $result as $row ) {
array_push($tmps,$row[0]);
}
echo json_encode($tmps);
?>
我的结果是[“31.375”,“30.687”,“29.5”] 但我需要它采用以下格式[31.375,30.687,29.5]
我试过
$array_final = json_encode($array_json);
$array_final = preg_replace('/"([a-zA-Z]+[a-zA-Z0-9]*)":/','$1:',$array_final);
echo $array_final;
但它不适合我:(