回显时$teststring
,我从 foreach 循环中得到下面的字符串。我需要删除尾随逗号并尝试echo rtrim($teststring,',');
从每个括号内的数据集之间删除逗号。如何仅删除最后一个逗号?
谢谢
[Date.UTC(2013,15,6), 9 ],[Date.UTC(2013,15,7), 9 ],[Date.UTC(2013,15,8), 9 ],[Date.UTC(2013,15,9), 9 ],[Date.UTC(2013,15,10), 9 ],[Date.UTC(2013,15,11), 9 ],[Date.UTC(2013,15,12), 9 ],
我需要删除结尾的逗号
foreach ($filtered_decoded as $results) {
$date = str_replace("-",",",$results['date']);
$pos = $results['position'];
$arr = array("data"=>"[Date.UTC(".$date."), ".$pos." ],");
// Tried to remove comma.
$teststring = implode($arr);
echo rtrim($teststring,',');
}