Thanks in advance for your help.
I intend to remove the last comma in the last string.
I did try rtrim but no success.
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ItemList",
"itemListElement": [
<?php $counter = 1; ?>
<?php foreach ($listingRecords as $listing): ?>
<?php foreach ($listing['uploads'] as $upload): ?>
{
"@type": "ListItem",
"position": "<?php echo $counter; ?>",
"item": {
"@type": "Movie",
"url": "<?php echo $listing['_link'] ?>",
"name": "<?php echo $listing['ref_no1'] ?>",
"image": "<?php echo $upload['urlPath'] ?>",
"dateCreated": "<?php echo $listing['date_added'] ?>",
"director": {
"@type": "Person",
"name": "abcdefg"
}
}
},
<?php $counter++ // increment counter ?>
<?php endforeach ?> <?php endforeach ?>
]
}
</script>
It's all about the output of the last listing.
There is a comma in the last part of listing.
"@type": "Person",
"name": "abcdefg"
}
}
}, <-- remove this comma in the last listing-->
]
}
</script>
Is there any method to remove the comma in the last listing?
Thanks a lot and sorry for trouble.