Home › Forums › Add-ons › Repeater Field › Output nested repeaters as arrays of arrays
Hello
I have following example of nested arrays (visulasation with my fields):
$tables = array(
'field_text_field_value1'=> array(
'sub_number_field_value_1' => array(
'i++' => sub_sub_number_field_v1,
'i++' => sub_sub_number_field_v2
),
'sub_number_field_value2' => array(
'i++' => sub_sub_number_field_v1,
'i++' => sub_sub_number_field_v2
),
'sub_number_field_value3' => array(
'i++' => sub_sub_number_field_v1,
'i++' => sub_sub_number_field_v2
),
),
'field_text_field_value2'=> array(
'sub_number_field_value_1' => array(
'i++' => sub_sub_number_field_v1,
'i++' => sub_sub_number_field_v2
),
'sub_number_field_value2' => array(
'i++' => sub_sub_number_field_v1,
'i++' => sub_sub_number_field_v2
),
'sub_number_field_value3' => array(
'i++' => sub_sub_number_field_v1,
'i++' => sub_sub_number_field_v2
),
),
);
return $tables;
I’d like to output my repeater loop as array above
Repeater loop:
if (have_rows('repeater_field', 'option')):
// loop through the rows of data
while (have_rows('repeater_field', 'option')): the_row();
// display a sub field value
the_sub_field('field_text_field');
if (have_rows('nested_repeater')):
while (have_rows('nested_repeater')): the_row();
the_sub_field('sub_number_field');
if (have_rows('nested_nested_repeater')):
$i = 3;
while (have_rows('nested_nested_repeater')): the_row();
$i++;
the_sub_field('sub_sub_number_field');
endwhile;
endif;
endwhile;
endif;
endwhile;
else :
// no rows found
endif;
};
Is it possible? Any tips where I could start? I would be very glad if someone could help me or point to some resolution.
Thank you
have you tried
$repeater = get_field('repeater_field', 'option');
echo '<pre>'; print_r($repeater); echo '</pre>';
The topic ‘Output nested repeaters as arrays of arrays’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.