This seems like such an easy thing to accomplish, so I’m sure I’m just missing it somehow.
What I’m looking to do is list all repeater field (line_chart_all_months) subfield values (line_chart_month) as a comma separated array (each value in single quotes).
For example, each subfield is a text input with a value such as Aug-22 (a total of 12, ending in Jul-23). The desired return needs to look like this:
‘Aug-22′,’Sep-22′,’Oct-22′,’Nov-22′,’Dec-22′,’Jan-23′,’Feb-23′,’Mar-23′,’Apr-23′,’May-23′,’Jun-23′,’Jul-23’
How is this accomplished?
I’ve tried:
<?php if(have_rows('line_chart_all_months') ): while(have_rows('line_chart_all_months') ) : the_row(); the_sub_field('line_chart_month');
endwhile; else : endif; ?>
But it returns this:
Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23
How do I get those separated with commas and single quotes for each value like above?
Thanks kindly in advance.