Rtrim不起作用

Help rtrim would not work whatever I do. I also tried to add whitespace after "," like it was on one of the topics i searched here

$this->items = array();
$xcount='(';
foreach ($items as $v) {
   $this->items[$v['id']] = $v;
   $xcount.=$v['id'].',';
};
rtrim($xcount, ",");

$xcount.=')';

The rtrim() returns a value and does not modify the original value. Please use it this way:

$xcount = rtrim($xcount, ",");

From the rtrim():

This function returns a string with whitespace (or other characters) stripped from the end of str.