Best practices - PHP rtrim() on Looping Recordset
What would be the best means to trim the last comma from a looping recordset result?
One option is putting the looped results in an array and then using the php rtrim() function.
echo rtrim($r_results, ',');
Would this be the best way or are there other options?
Current Code:
// Multiple Markers
var markers = [
<?php
$wa_startindex = 0;
while(!$Locations->atEnd()) {
$wa_startindex = $Locations->Index;
?>
['<?php echo($Locations->getColumnVal("pageName")); ?>',<?php echo($Locations->getColumnVal("lat")); ?>,<?php echo($Locations->getColumnVal("lng")); ?>],
<?php
$Locations->moveNext();
}
$Locations->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>
];
The goal being to get rid of that last comma after a group of bracketed results (......tions->getColumnVal("lng")); ?>],)