If Last Image
3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 8, 2010 (RSS)
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:
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?
<?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
Creative Director
JAM Graphics
Re: [jtedescojam] If Last Image
By Dave - December 8, 2010
Hi jtedescojam,
Give this a try:
Hope that helps, let me know if it works for you.
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
interactivetools.com
Re: [Dave] If Last Image
yeah that'll do it. Thanks Dave.
John Tedesco
Creative Director
JAM Graphics
Creative Director
JAM Graphics