Support

Account

Home Forums Add-ons Repeater Field Output nested repeaters as arrays of arrays

Helping

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>';
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Output nested repeaters as arrays of arrays’ is closed to new replies.