Separate List Output with Comma

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 2, 2018   (RSS)

By daniel - November 2, 2018

Hi mark99,

If you are using getRecords() to retrieve your record, you should be able to use the following:

<?php echo implode( ', ', $record['test:labels'] ); ?>

If you used a different method to access the record or "test:labels" is otherwise unavailable, this alternate method should also work:

<?php echo implode( ', ', listValues_unpack( $record['test'] )); ?>

Let me know if I can help with anything else!

Thanks,

Daniel
Technical Lead
interactivetools.com

By mark99 - November 2, 2018

I figure out I can also do it with this, but which approach is better (yours or mine)?

<?php echo join(', ', getListLabels('isp_list', 'sfbb_broadband_type_premium', $isp_listRecord['sfbb_broadband_type_premium'])); ?>

By daniel - November 2, 2018

Hi mark99,

They're both roughly equivalent, though I'd generally recommend my first example, if only because it's simplest. (My second example will only work if the list's values are the same as its labels). However, there are a few edge cases where it might not work, in which case yours is also a good option to try.

(Also implode() and join() are different names for the same function, so there's no difference there at all)

Thanks,

Daniel
Technical Lead
interactivetools.com