comma at the end of myData array causing error

Posted by user834421 
comma at the end of myData array causing error
July 18, 2011 07:54PM
I have created a list of possible chart items that are extracting values from the wordpress database. When I create the jscharts code to display the various items within the chart, all goes well until the last conditional. Because the myVar Array ends in a comma the chart does not render. I have tried different types of trimming the last character from the array that I found on google, but none seem to work.

Here is a clip of the conditional code I am using for the myData variable:

var myData = new Array(
	<?php if ($percent_apple != 0) {echo "['Apple'," .$percent_apple."]," ;} ?>
	<?php if ($percent_grape != 0) {echo "['Grape'," .$percent_grape."]," ;} ?> 
	<?php if ($percent_orange != 0) {echo "['Orange'," .$percent_orange."]," ;} ?>
);

Any help is appreciated, Thanks.
Sorry, you do not have permission to post/reply in this forum.