If Last Image

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 8, 2010   (RSS)

By jtedescojam - December 7, 2010

I'm using a 3rd party javascript for a flash slideshow and it contains a very simple imagearray which I've successfully integrated with CMSB.. this is the code:
<?php foreach ($home_page_image_rotaterRecord['photo'] as $upload): ?>
["<?php echo $upload['urlPath'] ?>", "", "", "<?php echo $upload['info1'] ?>"],
<?php endforeach ?>

Only problem is, the 'comma' has to come off the last image in the code, so I need the code to tell it to remove the comma if it's the last image. Can you help?
John Tedesco

Creative Director



JAM Graphics

Re: [jtedescojam] If Last Image

By Dave - December 8, 2010

Hi jtedescojam,

Give this a try:

<?php
$output = '';
foreach ($home_page_image_rotaterRecord['photo'] as $upload) {
$output .= '["' .$upload['urlPath']. '", "", "", "' .$upload['info1']. '"],';
}
$output = rtrim($output,','); // remove trailing comma
print $output;
?>


Hope that helps, let me know if it works for you.
Dave Edis - Senior Developer
interactivetools.com