假設的最後一個項目中刪除逗號我有此數組:PHP:從數組
['Jun 13',529],
['Jul 13',550],
['Aug 13',1005],
['Sep 13',1021],
['Oct 13',1027],
什麼是從上面的數組中刪除逗號的最後一個項目最快/最簡單的方法是什麼?
因此結果數組只包含這些值:
['Jun 13',529],
['Jul 13',550],
['Aug 13',1005],
['Sep 13',1021],
['Oct 13',1027]
實際代碼:提前
$i = 0;
while($graph_data = $con->db_fetch_array($graph_data_rs))
{
$year = $graph_data['year'];
$month = $graph_data['month'];
$count = $graph_data['count'];
$total_count = $graph_data['total_count'];
// for get last 2 digits of year
$shortYear = substr($year, -2, 2);
// for get month name in Jan,Feb format
$timestamp = mktime(0, 0, 0, $month, 1);
$monthName = date('M', $timestamp);
$data1 = "['".$monthName.' '.$shortYear."',".$total_count."],";
$i++;
}
謝謝...
你是怎麼產生這個 '數組'? –
這個數組的關鍵是什麼?這些值是字符串嗎? – Nanne
檢查'implode'函數 –