I have the script:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "<?php echo $rating;?>",
"reviewCount": "<?php echo $review_total; ?>"
},
"description": "<?php echo $description; ?>",
"name": "<?php echo $heading_title; ?>",
"image": "<?php echo $thumb; ?>",
"review": [
<?php foreach($reviewss as $review) { ?>
{
"@type": "Review",
"author": "<?php echo $review['author'];?>",
"datePublished": "<?php echo $review['date_added'];?>",
"description": "<?php echo $review['text'];?>",
"name": "<?php echo $review['author'];?>",
"reviewRating": {
"@type": "Rating",
"bestRating": "5",
"ratingValue": "<?php echo $review['rating'];?>",
"worstRating": "1"
}
}
<?php } ?>
]
}
</script>
It working fine if I have only one review. If I have several reviews I need add the commas after each piece of this:
{
"@type": "Review",
"author": "<?php echo $review['author'];?>",
"datePublished": "<?php echo $review['date_added'];?>",
"description": "<?php echo $review['text'];?>",
"name": "<?php echo $review['author'];?>",
"reviewRating": {
"@type": "Rating",
"bestRating": "5",
"ratingValue": "<?php echo $review['rating'];?>",
"worstRating": "1"
}
},
But after the last value, comma should be removed. Can anybody help? How to remove the last comma?