I have this PHP code:
foreach( $wpdb->get_results( ) as $key => $row) { echo \"[\'\". $row->DATE . \"\',\". $row->total_sales . \"],\"; }
You'll need variable to store comma state:
$comma = ""; ## don't need comma before first element foreach( $wpdb->get_results( ) as $key => $row) { echo $comma."['". $row->DATE . "',". $row->total_sales . "]"; $comma = ","; }