我將數據從mySQL數據庫返回到PHP數組中,但我不知道是什麼導致整個數組周圍的額外方括號。我試過玩過它,但我無法擺脫它。我後是如何從php數組中移除雙方括號
([ 「0.00」],[ 「0.00」],[ 「0.00」],[ 「1.80」],[ 「0.00」])
但就是我得到的是
([ 「0.00」],[ 「0.00」],[ 「0.00」],[ 「1.80」],[ 「0.00」])
我的PHP低於
$queryDate = date("Y-m-d");
$query = "SELECT windspeed FROM `weather_data` WHERE date_format(timestamp, '%Y-%m-%d') = '" . $queryDate . "'";
$result = db_query($query);
// If query failed, return `false`
if($result === false) {
return false;
}
$rows = array();
while ($row = mysqli_fetch_row($result)) {
$rows[] = $row;
}
echo $_GET['callback']. '('. json_encode($rows) . ')';
請有人可以解釋是什麼導致額外[],我怎麼可以刪除它們?
你使用'json_encode()' –
你有那個輸出,因爲那就是多維數組的json表示。它當然有可能得到你想要的輸出,但是輸出是用來做什麼的? – Steve
什麼是實際查詢輸出 – sujivasagam