显示基于ID或类名的数组

I've created an admin page for my wordpress theme to allow multiple images to be uploaded to my slideshow.

It works fine if there is only one slideshow form but if I add another one it no longer works as it should, the reason for this is that it counts the arrays and then takes a number away to display the amount of fields.

So instead of counting the arrays I would like to display them based on ID, so if there is 3 fields with the ID or class name then it will display 3 forms but this is all very new to me so I need a little help.

The id or class name is zzzclonedInput

Here's my form as it stands

function zzz_hero_image_option_callback() {
$hero_options = get_option( 'hero_options' ); 
$count=count($hero_options);
$totalimg=$count-4;
$html = '<div id="upload_zzz_sets">';
    for($i=1;$i<=$totalimg;$i++){ 
    if( isset( $hero_options['upload_zzz_link_1'] ) && $hero_options[ 'upload_zzz_link_1' ] ) { 
        $html .= '<div id="zzzclonedInput'.$i.'" class="zzzclonedInput">';
        $html .= '<input id="cs_product_menu_zzz_src_'.$i.'" type="text" size="36" name="hero_options[upload_zzz_link_'.$i.']" value="' . $hero_options['upload_zzz_link_'.$i.''] . '" /> <input id="cs_product_menu_zzz_src_'.$i.'_zzzbutton" type="button" value="Add / Change" class="button-secondary zzz-upload-button"  /> <div class="button zzzremove">-</div>';
        $html .= '</div>';
    }
    }
    $html .= '</div>';

    echo $html;
    ?> <div class="button zzzclone">Add an Image</div> <?php 
}

The bit I need to replace is this

$count=count($hero_options);
$totalimg=$count-4;

and

for($i=1;$i<=$totalimg;$i++){

Thanks for your help and if you need any other info let me know.