Remove HTML content if attribute is not set / variable attributes

I would prefer two array of images, captions.

For example:

I have added comments on the code for better understanding.

function wpse216239_slider_shortcode( $atts , $content = null ) {
    // Attributes
    $atts = shortcode_atts(
        array(
            'slides' => '', // one master attribute for slides
            'captions' => '' // one master attribute for captions
        ), 
        $atts,
        'myslidershortcode' 
    );

    $slides = explode(';;', $atts['slides']); // slide urls separated by ;;
    $captions = explode(';;', $atts['captions']); // caption texts separated by ;;

    if(empty($slides)){
        return '<!-- no slides -->';
    }

    $html="
    <div class="col-lg-7">
        <div class="carousel slide padtop" data-ride="carousel" id=
        "carousel-example-generic">
            <!-- Wrapper for slides -->
            <div class="carousel-inner" role="listbox">
    ";


    $active="active";
    $i = 0;

    foreach($slides as $src){
        $caption = isset($captions[$i]) ? $captions[$i] : ''; 

        $html .= "<div class=\"item " . esc_attr( $active ) . "\">";
        $html .= "<img src=\"" . esc_url( $src ) . "\" class=\"img-responsive\">";

        if($caption) // only add caption if available
            $html .= "<div class=\"carousel-caption\">" . esc_html( $caption ) . "</div>"

        $html .= '</div>';

        $active="";
        $i++;
    }

    $html .= '</div></div></div>';

}
add_shortcode( 'slider', 'wpse216239_slider_shortcode' );

This code will only generate slider html if images are given to the shortcode. Separate image url and captions by ;;

Implementation

[slider 
    slides="http://example.com/image1;;http://example.com/image2"
    captions="My caption1;;Mycaption2"
]

Code is given for demonstration purpose. It is not tested and should not put in a production site without testing.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)