Removing last comma in PHP?

前端 未结 7 2141
忘掉有多难
忘掉有多难 2020-11-28 16:36

I have this PHP code:

foreach( $wpdb->get_results(
) as $key => $row) {

echo \"[\'\". $row->DATE . \"\',\". $row->total_sales . \"],\";

}
         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 16:53

    php has a trim function, give it a string and the comma.

    $s = trim ($s,",")
    

提交回复
热议问题