I'm having a bit of trouble with an annoying ',' during the iteration of a PHP array to produce a Javascript array. Essentially, what I have is this:
<?php
$array = array(StdObject,StdObject,StdObject);
?>
//later that page...in JavaScript
var list = [
<?php foreach($array as $value):?>
'<?=$value->some_letter_field?>',
<?endforeach;?>
];
Unfortunatly, what this code does is produce output that looks like this:
var list = ['a','b','c',];
Notice that extra comma in the JavaScript array? This is causing some issues. How would I go about re-writing this PHP snippet so that extra comma doesn't get printed, producing a properly formatted JavaScript array?
The expected output should be:
var list = ['a','b','c'];
I appreciate your help in advance.